userpanel: add cli params

This commit is contained in:
boyska 2018-11-13 14:51:07 +01:00
parent 7bcaf2a79a
commit f17b8179b6
3 changed files with 18 additions and 4 deletions

View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"net/http" "net/http"
@ -9,10 +10,20 @@ import (
) )
func main() { func main() {
ha := panelui.HeaderAuth{AllowedNames: []string{"feedati-fe"}, RequireUser: true} allowedName := flag.String("allowed-name", "", "Name allowed to forward auth")
addr := flag.String("listen-addr", ":8000", "Address to listen on")
flag.Parse()
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 := negroni.New(negroni.NewRecovery(), negroni.NewLogger(), ha)
n.UseHandler(panelui.GetMux()) n.UseHandler(panelui.GetMux())
addr := ":8000" fmt.Println("Listening on", *addr)
fmt.Println("Listening on", addr) http.ListenAndServe(*addr, n)
http.ListenAndServe(addr, n)
} }

1
go.mod
View file

@ -8,6 +8,7 @@ require (
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
github.com/kr/pretty v0.1.0 // indirect github.com/kr/pretty v0.1.0 // indirect
github.com/namsral/flag v1.7.4-pre
github.com/onsi/gomega v1.4.2 // indirect github.com/onsi/gomega v1.4.2 // indirect
github.com/pkg/errors v0.8.0 github.com/pkg/errors v0.8.0
github.com/urfave/negroni v1.0.0 github.com/urfave/negroni v1.0.0

2
go.sum
View file

@ -21,6 +21,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/namsral/flag v1.7.4-pre h1:b2ScHhoCUkbsq0d2C15Mv+VU8bl8hAXV8arnWiOHNZs=
github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I= github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=