whoisthis/init.go

26 lines
490 B
Go
Raw Permalink Normal View History

2025-01-12 11:47:44 +00:00
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,
}
}