Ejemplo n.º 1
0
func NewAppServer(mode RunMode, config *AppConfig, logger *AppLogger) *AppServer {
	server := &AppServer{
		mode:      mode,
		config:    config,
		logger:    logger,
		requestId: DefaultHttpRequestId,
	}

	// init Route
	server.AppRoute = NewAppRoute("/", server)

	// init router
	server.router = httprouter.New()
	server.router.HandleMethodNotAllowed = false // strict for RESTful

	// overwrite
	server.pool.New = func() interface{} {
		return NewContext(server)
	}

	return server
}
Ejemplo n.º 2
0
Archivo: server.go Proyecto: dolab/gogo
func NewAppServer(mode RunMode, config *AppConfig, logger Logger) *AppServer {
	server := &AppServer{
		mode:      mode,
		config:    config,
		logger:    logger,
		requestId: DefaultHttpRequestId,
	}

	// init Route
	server.AppRoute = NewAppRoute("/", server)

	// init default handler with httprouter.Router
	handler := httprouter.New()
	handler.RedirectTrailingSlash = false
	handler.HandleMethodNotAllowed = false // strict for RESTful
	server.handler = handler

	// overwrite
	server.pool.New = func() interface{} {
		return NewContext(server)
	}

	return server
}