feat: add API handler (register, login, skin, launcher, servers, manifest)

- register: POST /api/web/register — create user with SHA-256 password hash
- login: POST /api/web/login — credentials check + session token
- uploadSkin: POST /api/web/profile/skin — PNG upload, SHA-1 CAS storage
- launcherLatest: GET /api/launcher/latest — latest launcher version + download URL
- serversList: GET /api/servers.json — active modpacks list
- instanceManifest: GET /api/instances/{slug}/manifest.json — modpack manifest
- serveSkin: GET /skins/{hash}.png — skin file serving with cache headers
- PathValue-based routing (Go 1.22+)

Co-Authored-By: OWL <noreply@anthropic.com>
This commit is contained in:
2026-05-26 13:31:22 +03:00
parent d205320e0e
commit 475ff9bfa2
2 changed files with 384 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import (
"syscall"
"time"
"gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/api"
"gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/auth"
"gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/config"
"gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/database"
@@ -41,7 +42,11 @@ func main() {
authHandler := auth.NewHandler(db, cfg)
authHandler.RegisterRoutes(mux)
// TODO: register API, Admin, CAS routes.
// Public API.
apiHandler := api.NewHandler(db, cfg)
apiHandler.RegisterRoutes(mux)
// TODO: register Admin, CAS routes.
addr := ":" + itoa(cfg.Port)
srv := &http.Server{