Add auth middleware

This commit is contained in:
2025-05-24 02:51:25 +04:00
parent b6eaaf7331
commit 1eecbafd07
9 changed files with 172 additions and 57 deletions

View File

@@ -1,3 +1,19 @@
package middleware
import (
"net/http"
"github.com/aykhans/bsky-feedgen/pkg/types"
)
type ContextKey string
func GetValue[T any](r *http.Request, key ContextKey) (T, error) {
value, ok := r.Context().Value(key).(T)
if ok == false {
var zero T
return zero, types.ErrNotfound
}
return value, nil
}