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

37 lines
834 B
Go
Raw Permalink Normal View History

2018-09-30 11:06:46 +02:00
package main
import (
"fmt"
"net/http"
2018-11-13 15:09:33 +01:00
"os"
"github.com/namsral/flag"
2018-09-30 14:05:25 +02:00
"git.lattuga.net/boyska/feedpanel/panelui"
2018-09-30 14:05:25 +02:00
"github.com/urfave/negroni"
2018-09-30 11:06:46 +02:00
)
func main() {
2018-12-18 00:03:59 +01:00
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
2018-11-13 15:09:33 +01:00
fs := flag.NewFlagSetWithEnvPrefix(os.Args[0], "PANEL", 0)
allowedName := fs.String("allowed-name", "", "Name allowed to forward auth")
2018-12-18 00:03:59 +01:00
addr := fs.String("listen-addr", ":"+port, "Address to listen on")
2018-11-13 15:09:33 +01:00
fs.Parse(os.Args[1:])
2018-11-13 14:51:07 +01:00
var allowedNames []string
if *allowedName != "" {
allowedNames = []string{*allowedName}
} else {
allowedNames = []string{}
}
ha := panelui.HeaderAuth{AllowedNames: allowedNames, RequireUser: true}
2018-09-30 14:05:25 +02:00
n := negroni.New(negroni.NewRecovery(), negroni.NewLogger(), ha)
n.UseHandler(panelui.GetMux())
2018-11-13 14:51:07 +01:00
fmt.Println("Listening on", *addr)
http.ListenAndServe(*addr, n)
2018-09-30 11:06:46 +02:00
}