teg/backend/routes.go
2026-05-12 15:29:56 +02:00

24 lines
715 B
Go

// backend\routes.go
package main
import "net/http"
func (s *Server) Routes() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("GET /health", s.handleHealth)
mux.HandleFunc("POST /auth/register", s.handleRegister)
mux.HandleFunc("POST /auth/login", s.handleLogin)
mux.HandleFunc("POST /auth/logout", s.handleLogout)
mux.HandleFunc("GET /auth/me", s.requireAuth(s.handleMe))
mux.HandleFunc("GET /devices", s.requireAuth(s.handleListDevices))
mux.HandleFunc("POST /devices", s.requireAuth(s.handleCreateDevice))
mux.HandleFunc("PUT /devices/{id}", s.requireAuth(s.handleUpdateDevice))
mux.HandleFunc("GET /devices/{id}/history", s.requireAuth(s.handleListDeviceHistory))
return s.cors(mux)
}