whoisthis/example_test.go

29 lines
492 B
Go
Raw Permalink Normal View History

2025-01-12 11:47:44 +00:00
package whoisthis_test
import (
"net/http"
"git.bivouac.wiki/use/whoisthis"
)
func Deny(w http.ResponseWriter, r *http.Request) {
http.Error(w, "please sign-in", http.StatusUnauthorized)
}
func lookup(r *http.Request) (string, error) {
user := "abcd"
return user, nil
}
func HomeRoute(w http.ResponseWriter, r *http.Request) {
}
func ExampleSession() {
wis := whoisthis.New(store, cache, lookup, Deny)
mux := http.NewServeMux()
mux.Handle("/home", wis.Authed(HomeRoute()))
}