MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / Middleware

Method Middleware

internal/auth/auth.go:63–72  ·  view source on GitHub ↗
(next http.Handler)

Source from the content-addressed store, hash-verified

61}
62
63func (m *Manager) Middleware(next http.Handler) http.Handler {
64 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
65 token := bearerToken(r.Header.Get("Authorization"))
66 if token == "" || !m.valid(token) {
67 writeJSON(w, http.StatusUnauthorized, map[string]any{"error": "unauthorized"})
68 return
69 }
70 next.ServeHTTP(w, r)
71 })
72}
73
74func (m *Manager) HandleLogin(w http.ResponseWriter, r *http.Request) {
75 if r.Method != http.MethodPost {

Callers 2

TestLoginMeLogoutFunction · 0.95
RunFunction · 0.95

Calls 5

validMethod · 0.95
bearerTokenFunction · 0.85
ServeHTTPMethod · 0.80
writeJSONFunction · 0.70
GetMethod · 0.65

Tested by 1

TestLoginMeLogoutFunction · 0.76