mirror of
https://github.com/elyby/chrly.git
synced 2024-12-29 00:10:19 +05:30
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
|
package ui
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"net/http"
|
||
|
"time"
|
||
|
|
||
|
"github.com/gorilla/mux"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
|
||
|
}
|
||
|
|
||
|
func Start(cfg Config, s *uiService, lst net.Listener) {
|
||
|
router := mux.NewRouter().StrictSlash(true)
|
||
|
|
||
|
router.HandleFunc("/skins/{username}", s.Skin).Methods("GET")
|
||
|
router.HandleFunc("/cloaks/{username}", s.Cape).Methods("GET")
|
||
|
router.HandleFunc("/textures/{username}", s.Textures).Methods("GET")
|
||
|
router.HandleFunc("/textures/signed/{username}", s.SignedTextures).Methods("GET")
|
||
|
router.HandleFunc("/skins/{username}/face", s.Face).Methods("GET")
|
||
|
router.HandleFunc("/skins/{username}/face.png", s.Face).Methods("GET")
|
||
|
// Legacy
|
||
|
router.HandleFunc("/minecraft.php", s.MinecraftPHP).Methods("GET")
|
||
|
router.HandleFunc("/skins/", s.SkinGET).Methods("GET")
|
||
|
router.HandleFunc("/cloaks/", s.CapeGET).Methods("GET")
|
||
|
// 404
|
||
|
router.NotFoundHandler = http.HandlerFunc(NotFound)
|
||
|
|
||
|
server := &http.Server{
|
||
|
ReadTimeout: 60 * time.Second,
|
||
|
WriteTimeout: 60 * time.Second,
|
||
|
MaxHeaderBytes: 1 << 16,
|
||
|
Handler: router,
|
||
|
}
|
||
|
|
||
|
go server.Serve(lst)
|
||
|
}
|