mirror of
https://github.com/Kugelschieber/migo.git
synced 2026-01-18 06:40:29 +00:00
34 lines
612 B
Go
34 lines
612 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/go-chi/jwtauth/v5"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func DebugHandler(w http.ResponseWriter, r *http.Request) {
|
|
_, claims, err := jwtauth.FromContext(r.Context())
|
|
|
|
if err != nil {
|
|
log.Printf("Error reading token: %v", err)
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
data, err := json.Marshal(struct {
|
|
Claims map[string]any `json:"claims"`
|
|
}{
|
|
claims,
|
|
})
|
|
|
|
if err != nil {
|
|
log.Printf("Error marshalling response: %v", err)
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write(data)
|
|
}
|