皮肤静态资源提供

This commit is contained in:
xmdhs 2023-09-12 20:45:23 +08:00
parent 63ffeeffb7
commit 50234d7070
No known key found for this signature in database
GPG Key ID: E809D6D43DEFCC95
2 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
"strings"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
@ -78,3 +79,11 @@ func (y *Yggdrasil) YggdrasilRoot() httprouter.Handle {
} }
} }
func (y *Yggdrasil) TextureAssets() httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
w.Header().Set("Content-Type", "image/png")
r.RequestURI = strings.TrimPrefix(r.RequestURI, "/texture/")
http.FileServer(http.Dir(y.config.TexturePath)).ServeHTTP(w, r)
}
}

View File

@ -40,6 +40,8 @@ func newYggdrasil(r *httprouter.Router, handelY yggdrasil.Yggdrasil) error {
r.POST("/api/yggdrasil/minecraftservices/player/certificates", warpHJSON(handelY.PlayerCertificates())) r.POST("/api/yggdrasil/minecraftservices/player/certificates", warpHJSON(handelY.PlayerCertificates()))
r.GET("/api/yggdrasil", warpHJSON(handelY.YggdrasilRoot())) r.GET("/api/yggdrasil", warpHJSON(handelY.YggdrasilRoot()))
r.GET("/texture/*filepath", handelY.TextureAssets())
return nil return nil
} }