@@ -6,33 +6,20 @@ import (
66
77 "github.com/go-sphere/httpx"
88 "github.com/go-sphere/sphere/cache/memory"
9- "github.com/go-sphere/sphere/server/middleware/cors"
109 "github.com/go-sphere/sphere/storage/fileserver"
1110 "github.com/go-sphere/sphere/storage/local"
1211)
1312
14- // HTTPConfig contains HTTP server configuration for the file service.
15- type HTTPConfig struct {
16- Cors []string `json:"cors" yaml:"cors"`
17- }
18-
19- // Config contains the complete configuration for the file web service.
20- type Config struct {
21- HTTP HTTPConfig `json:"http" yaml:"http"`
22- }
23-
2413// Web provides a file upload and download web service with S3-compatible storage.
2514type Web struct {
26- config * Config
2715 engine httpx.Engine
2816 server * http.Server
2917 storage * fileserver.S3Adapter
3018}
3119
3220// NewWebServer creates a new file web server with the given configuration and storage adapter.
33- func NewWebServer (config * Config , engine httpx.Engine , storage * fileserver.S3Adapter ) * Web {
21+ func NewWebServer (engine httpx.Engine , storage * fileserver.S3Adapter ) * Web {
3422 return & Web {
35- config : config ,
3623 engine : engine ,
3724 storage : storage ,
3825 }
@@ -61,7 +48,6 @@ func (w *Web) Identifier() string {
6148// Start begins serving the file web server with upload and download endpoints.
6249// It configures CORS, registers file upload/download handlers, and starts the HTTP server.
6350func (w * Web ) Start (ctx context.Context ) error {
64- w .engine .Use (cors .NewCORS ())
6551 w .storage .RegisterPutFileUploader (w .engine .Group ("/" ))
6652 w .storage .RegisterFileDownloader (w .engine .Group ("/" ), fileserver .WithCacheControl (3600 ))
6753 return w .engine .Start ()
0 commit comments