Static Files
Live on this serverServes files from a directory or resource tree.
using GenHTTP.Api.Content;
using GenHTTP.Modules.Files;
public static class StaticFileSample
{
public static IHandlerBuilder Create()
{
/*
*
* Serves files from a given directory or resource tree.
*
* See https://genhttp.org/documentation/content/handlers/files/
*
*/
// serves the files shipped with this website (resources/samples/files),
// use Assets.From("./") to serve a directory
// e.g. GET /samples/static-files/README.md
return Assets.From(Resources.Tree("samples/files"));
}
}Try it
Send the requests to the sample running on this server - change the path, headers or body as you like, or copy them as curl commands.
Fetch a file
curl -i 'https://genhttp.org/samples/static-files/README.md'Fetch another one
curl -i 'https://genhttp.org/samples/static-files/books.csv'