summaryrefslogtreecommitdiff
path: root/internal/api/client/fileserver/fileserver.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/client/fileserver/fileserver.go')
-rw-r--r--internal/api/client/fileserver/fileserver.go15
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
}