From 2ef530daa47b301a40c1ee93cd43b8f36fc68c0b Mon Sep 17 00:00:00 2001 From: tjpcc Date: Tue, 17 Jan 2023 15:59:29 -0700 Subject: pull request, response, handlers out of the gemini package --- contrib/fs/file.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'contrib/fs/file.go') diff --git a/contrib/fs/file.go b/contrib/fs/file.go index cdcd1a9..8cb1aeb 100644 --- a/contrib/fs/file.go +++ b/contrib/fs/file.go @@ -6,15 +6,16 @@ import ( "mime" "strings" + "tildegit.org/tjp/gus" "tildegit.org/tjp/gus/gemini" ) // FileHandler builds a handler function which serves up a file system. -func FileHandler(fileSystem fs.FS) gemini.Handler { - return func(ctx context.Context, req *gemini.Request) *gemini.Response { +func FileHandler(fileSystem fs.FS) gus.Handler { + return func(ctx context.Context, req *gus.Request) *gus.Response { file, err := fileSystem.Open(strings.TrimPrefix(req.Path, "/")) if isNotFound(err) { - return gemini.NotFound("Resource does not exist.") + return nil } if err != nil { return gemini.Failure(err) @@ -26,7 +27,7 @@ func FileHandler(fileSystem fs.FS) gemini.Handler { } if isDir { - return gemini.NotFound("Resource does not exist.") + return nil } return gemini.Success(mediaType(req.Path), file) -- cgit v1.2.3