25 lines
490 B
Go
25 lines
490 B
Go
package whoisthis
|
|
|
|
import "net/http"
|
|
|
|
type kv interface {
|
|
Get(string) any
|
|
Set(string) any
|
|
}
|
|
type WhoIsThis struct {
|
|
cache kv
|
|
store kv
|
|
LookupReqFn LookupFn
|
|
DenyFn respond
|
|
}
|
|
type LookupFn func(r *http.Request) (string, error)
|
|
type respond func(w http.ResponseWriter, r *http.Request)
|
|
|
|
func New(store kv, cache kv, lookup LookupFn, deny respond) WhoIsThis {
|
|
return WhoIsThis{
|
|
store: store,
|
|
cache: cache,
|
|
LookupReqFn: lookup,
|
|
DenyFn: deny,
|
|
}
|
|
}
|