Files
LINUX-AETHERFORGE/internal/api/handlers/auth.go
drjones 3678b199d0
Some checks failed
Test / test (push) Has been cancelled
Initial commit: AetherForge Linux (forge-mesh) v0.1.0-dev
2026-07-04 09:31:23 +00:00

29 lines
636 B
Go

package handlers
import (
"encoding/json"
"net/http"
"forge-mesh/internal/auth"
)
// AuthHandlers serves login and WS ticket endpoints.
type AuthHandlers struct {
Tickets *auth.TicketStore
}
func (h *AuthHandlers) WSTicket(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
ticket, err := h.Tickets.Issue()
if err != nil {
http.Error(w, "ticket error", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]string{"ticket": ticket})
}