Esempio n. 1
0
func (p *program) initWebServer() *httpway.Server {

	server := httpway.NewServer(nil)
	server.Addr = GetConfig().WebServerConfig().Address
	server.Handler = p.router

	return server
}
Esempio n. 2
0
func main() {
	router := httpway.New()

	public := router.Middleware(AccessLogger)
	private := public.Middleware(AuthCheck)

	public.GET("/public", testHandler("public"))

	private.GET("/private", testHandler("private"))
	private.GET("/stop", stopServer)

	server = httpway.NewServer(nil)
	server.Addr = ":8080"
	server.Handler = router

	if err := server.Start(); err != nil {
		fmt.Println("Error", err)
		return
	}

	if err := server.WaitStop(10 * time.Second); err != nil {
		fmt.Println("Error", err)
	}
}