1
0
Fork 0
forked from boyska/feedpanel
feedpanel/cmd/userpanel/main.go

36 lines
834 B
Go

package main
import (
"fmt"
"net/http"
"os"
"github.com/namsral/flag"
"git.lattuga.net/boyska/feedpanel/panelui"
"github.com/urfave/negroni"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
fs := flag.NewFlagSetWithEnvPrefix(os.Args[0], "PANEL", 0)
allowedName := fs.String("allowed-name", "", "Name allowed to forward auth")
addr := fs.String("listen-addr", ":"+port, "Address to listen on")
fs.Parse(os.Args[1:])
var allowedNames []string
if *allowedName != "" {
allowedNames = []string{*allowedName}
} else {
allowedNames = []string{}
}
ha := panelui.HeaderAuth{AllowedNames: allowedNames, RequireUser: true}
n := negroni.New(negroni.NewRecovery(), negroni.NewLogger(), ha)
n.UseHandler(panelui.GetMux())
fmt.Println("Listening on", *addr)
http.ListenAndServe(*addr, n)
}