From c22799fa12c99932fc4620fce2dc0994567a52af Mon Sep 17 00:00:00 2001 From: tjp Date: Tue, 14 Nov 2023 09:39:53 -0700 Subject: bugfixes from the Protocol refactor --- contrib/fs/gopher.go | 13 ++++++++++++- contrib/fs/handlers.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'contrib/fs') diff --git a/contrib/fs/gopher.go b/contrib/fs/gopher.go index 209a4ec..22cdbc3 100644 --- a/contrib/fs/gopher.go +++ b/contrib/fs/gopher.go @@ -29,7 +29,18 @@ func GopherDirectoryDefault(fsroot, urlroot string, settings *gophermap.FileSyst } handler := directoryDefault(gopher.ServerProtocol, fsroot, urlroot, false, settings.DirMaps...) - return gophermap.ExtendMiddleware(fsroot, urlroot, settings)(handler) + + // force response status to MenuType since we hit a directory default file + menuHandler := sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { + response := handler.Handle(ctx, request) + if response == nil { + return response + } + response.Status = gopher.MenuType + return response + }) + + return gophermap.ExtendMiddleware(fsroot, urlroot, settings)(menuHandler) } // GopherDirectoryListing produces a listing of the contents of any requested directories. diff --git a/contrib/fs/handlers.go b/contrib/fs/handlers.go index 75422d9..02b7d38 100644 --- a/contrib/fs/handlers.go +++ b/contrib/fs/handlers.go @@ -79,7 +79,7 @@ func directoryDefault( if err != nil { return protocol.TemporaryServerError(err) } - return protocol.Success(filepath.Base(fpath), file) + return protocol.Success(fpath, file) } return nil -- cgit v1.2.3