forked from boyska/feedpanel
27 lines
598 B
Go
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)
|
|
}
|