From 50234d7070d8603c2c3edb58468d28aa5a70b656 Mon Sep 17 00:00:00 2001 From: xmdhs Date: Tue, 12 Sep 2023 20:45:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9A=AE=E8=82=A4=E9=9D=99=E6=80=81=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8F=90=E4=BE=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handle/yggdrasil/yggdrasil.go | 9 +++++++++ server/route/route.go | 2 ++ 2 files changed, 11 insertions(+) diff --git a/handle/yggdrasil/yggdrasil.go b/handle/yggdrasil/yggdrasil.go index 7232258..7dacc00 100644 --- a/handle/yggdrasil/yggdrasil.go +++ b/handle/yggdrasil/yggdrasil.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "net/url" + "strings" "github.com/go-playground/validator/v10" "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) + } +} diff --git a/server/route/route.go b/server/route/route.go index 1e02075..9dcf8f7 100644 --- a/server/route/route.go +++ b/server/route/route.go @@ -40,6 +40,8 @@ func newYggdrasil(r *httprouter.Router, handelY yggdrasil.Yggdrasil) error { r.POST("/api/yggdrasil/minecraftservices/player/certificates", warpHJSON(handelY.PlayerCertificates())) r.GET("/api/yggdrasil", warpHJSON(handelY.YggdrasilRoot())) + + r.GET("/texture/*filepath", handelY.TextureAssets()) return nil }