diff options
author | 2021-12-20 15:19:53 +0100 | |
---|---|---|
committer | 2021-12-20 15:19:53 +0100 | |
commit | cb8688f4298a1a3ed5e28565004588be3c071df0 (patch) | |
tree | 038b196e914b949857bf8b7c00f22374408bc1ca /internal/api/client/fileserver/fileserver.go | |
parent | return first offer when no accept header set (#351) (diff) | |
download | gotosocial-cb8688f4298a1a3ed5e28565004588be3c071df0.tar.xz |
Remove unnecessary storage config variables (#344)
* rewire config to not use extraneous serve vars
* rename 'file' to 'local' for consistency
* use Type and Size again
Diffstat (limited to 'internal/api/client/fileserver/fileserver.go')
-rw-r--r-- | internal/api/client/fileserver/fileserver.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/internal/api/client/fileserver/fileserver.go b/internal/api/client/fileserver/fileserver.go index 092a15256..c7b08a8e1 100644 --- a/internal/api/client/fileserver/fileserver.go +++ b/internal/api/client/fileserver/fileserver.go @@ -22,14 +22,15 @@ import ( "fmt" "net/http" - "github.com/spf13/viper" "github.com/superseriousbusiness/gotosocial/internal/api" - "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/router" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) const ( + // FileServeBasePath forms the first part of the fileserver path. + FileServeBasePath = "/" + uris.FileserverPath // AccountIDKey is the url key for account id (an account ulid) AccountIDKey = "account_id" // MediaTypeKey is the url key for media type (usually something like attachment or header etc) @@ -43,20 +44,20 @@ const ( // FileServer implements the RESTAPIModule interface. // The goal here is to serve requested media files if the gotosocial server is configured to use local storage. type FileServer struct { - processor processing.Processor - storageServeBasePath string + processor processing.Processor } // New returns a new fileServer module func New(processor processing.Processor) api.ClientModule { return &FileServer{ - processor: processor, - storageServeBasePath: viper.GetString(config.Keys.StorageServeBasePath), + processor: processor, } } // Route satisfies the RESTAPIModule interface func (m *FileServer) Route(s router.Router) error { - s.AttachHandler(http.MethodGet, fmt.Sprintf("%s/:%s/:%s/:%s/:%s", m.storageServeBasePath, AccountIDKey, MediaTypeKey, MediaSizeKey, FileNameKey), m.ServeFile) + // something like "/fileserver/:account_id/:media_type/:media_size/:file_name" + fileServePath := fmt.Sprintf("%s/:%s/:%s/:%s/:%s", FileServeBasePath, AccountIDKey, MediaTypeKey, MediaSizeKey, FileNameKey) + s.AttachHandler(http.MethodGet, fileServePath, m.ServeFile) return nil } |