This commit is contained in:
xujiang
2025-07-10 18:09:11 +08:00
parent 5cbdc5af73
commit 604b9e59ba
95 changed files with 23709 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"net/http"
"photography-backend/internal/config"
"photography-backend/internal/handler"
@ -26,6 +27,15 @@ func main() {
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
// 添加静态文件服务
server.AddRoute(rest.Route{
Method: http.MethodGet,
Path: "/uploads/:path",
Handler: func(w http.ResponseWriter, r *http.Request) {
http.StripPrefix("/uploads/", http.FileServer(http.Dir(c.FileUpload.UploadDir))).ServeHTTP(w, r)
},
})
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}