1
0
Fork 0
forked from boyska/feedpanel
feedpanel/cmd/userpanel/main.go
2018-09-30 23:17:57 +02:00

27 lines
598 B
Go

package main
import (
"fmt"
"net/http"
"github.com/urfave/negroni"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
user := r.Context().Value(keyUser)
if user == nil {
panic("Authentication middleware failed!")
}
w.WriteHeader(200)
fmt.Fprintf(w, "Hello, %s\n", user)
})
ha := HeaderAuth{AllowedNames: []string{"feedati-fe"}, RequireUser: true}
n := negroni.New(negroni.NewRecovery(), negroni.NewLogger(), ha)
n.UseHandler(mux)
addr := ":8000"
fmt.Println("Listening on", addr)
http.ListenAndServe(addr, n)
}