initial commit
This commit is contained in:
13
magic/state.go
Normal file
13
magic/state.go
Normal file
@ -0,0 +1,13 @@
|
||||
package magic
|
||||
|
||||
import "net/http"
|
||||
|
||||
type State[T any] struct {
|
||||
Data T
|
||||
}
|
||||
|
||||
func RegisterState[T any](data T) {
|
||||
RegisterExtractor(State[T]{}, func(r *http.Request) (any, error) {
|
||||
return State[T]{Data: data}, nil
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user