main.go 770 B

1234567891011121314151617181920212223242526272829303132
  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "os"
  6. "github.com/namsral/flag"
  7. "git.lattuga.net/boyska/feedpanel/panelui"
  8. "github.com/urfave/negroni"
  9. )
  10. func main() {
  11. fs := flag.NewFlagSetWithEnvPrefix(os.Args[0], "PANEL", 0)
  12. allowedName := fs.String("allowed-name", "", "Name allowed to forward auth")
  13. addr := fs.String("listen-addr", ":8000", "Address to listen on")
  14. fs.Parse(os.Args[1:])
  15. var allowedNames []string
  16. if *allowedName != "" {
  17. allowedNames = []string{*allowedName}
  18. } else {
  19. allowedNames = []string{}
  20. }
  21. ha := panelui.HeaderAuth{AllowedNames: allowedNames, RequireUser: true}
  22. n := negroni.New(negroni.NewRecovery(), negroni.NewLogger(), ha)
  23. n.UseHandler(panelui.GetMux())
  24. fmt.Println("Listening on", *addr)
  25. http.ListenAndServe(*addr, n)
  26. }