summaryrefslogtreecommitdiff
path: root/contrib/fs/file.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-01-17 15:59:29 -0700
committertjpcc <tjp@ctrl-c.club>2023-01-17 15:59:29 -0700
commit2ef530daa47b301a40c1ee93cd43b8f36fc68c0b (patch)
treeb9753719f5f0e5312bb5008d40f40247ce14e15a /contrib/fs/file.go
parent30e21f8513d49661cb6e1583d301e34e898d48a9 (diff)
pull request, response, handlers out of the gemini package
Diffstat (limited to 'contrib/fs/file.go')
-rw-r--r--contrib/fs/file.go9
1 files changed, 5 insertions, 4 deletions
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)