x/cmd/auth-demo/main.go
Colin Henry 6e60671cfd WIP
2020-05-20 23:18:58 -07:00

35 lines
644 B
Go
Executable File

package main
import (
"net/http"
"os"
"github.com/codegangsta/negroni"
"github.com/jchenry/jchenry/auth"
_http "github.com/jchenry/jchenry/http"
)
func main() {
auth.Init()
StartServer()
}
func StartServer() {
auth.PrintConfig()
s := _http.NewServer(negroni.New(), _http.NewJulienschmidtHTTPRouter()).
Static("/public/*filepath", http.Dir("public/")).
Service("", auth.Service(auth.FromEnv())).
Get("/", "", http.HandlerFunc(HomeHandler))
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
s.Run(":" + port)
}
func HomeHandler(w http.ResponseWriter, r *http.Request) {
_http.RenderTemplate(w, "home", nil)
}