123456789101112131415161718192021222324252627282930313233343536 |
- 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)
- }
|