mirror of
https://github.com/aykhans/bsky-feedgen.git
synced 2025-07-17 21:34:00 +00:00
Add auth middleware
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user