29 lines
492 B
Go
29 lines
492 B
Go
|
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()))
|
||
|
}
|