Пример #1
0
func NewHandler(documentRoot string) http.Handler {
	glog.V(2).Infof("root: %s", documentRoot)
	fileServer := cacheheader.New(contenttype.New(http.FileServer(http.Dir(documentRoot))))
	handlerFinder := part.New("")
	handlerFinder.RegisterHandler("/", fileServer)
	handlerFinder.RegisterHandler("/css", fileServer)
	handlerFinder.RegisterHandler("/js", fileServer)
	handlerFinder.RegisterHandler("/images", fileServer)
	return log_handler.New(fallback.New(handlerFinder, static.NewWithReturnCode("not found", 404)))
}
func (h *handlerConfiguration) GetHandler() http.Handler {
	glog.V(2).Infof("root: %s", h.documentRoot)
	fileServer := cacheheader.New(contenttype.New(http.FileServer(http.Dir(h.documentRoot))))
	handlerFinder := part.New("")
	handlerFinder.RegisterHandler("/", fileServer)
	handlerFinder.RegisterHandler("/css", fileServer)
	handlerFinder.RegisterHandler("/js", fileServer)
	handlerFinder.RegisterHandler("/images", fileServer)
	handlerFinder.RegisterHandler("/status", h.handle_errors(booking_status_handler.New()))
	handlerFinder.RegisterHandler("/calendar", h.handle_errors(booking_calendar_handler.New(h.calendarWriter.WriteCalendar, h.configService.GetStringDefault)))
	handlerFinder.RegisterHandlerFinder("/date", h.createDateHandlerFinder("/date"))
	handlerFinder.RegisterHandlerFinder("/model", h.createModelHandlerFinder("/model"))
	handlerFinder.RegisterHandlerFinder("/shooting", h.createShootingHandlerFinder("/shooting"))
	handlerFinder.RegisterHandlerFinder("/user", h.createUserHandlerFinder("/user"))
	handlerFinder.RegisterHandlerFinder("/config", h.createConfigHandlerFinder("/config"))
	handlerFinder.RegisterHandlerFinder("/authentication", h.createAuthenticationHandlerFinder("/authentication"))
	handlerFinder.RegisterHandlerFinder("/date_user", h.createDateUserHandler("/date_user"))
	handlerFinder.RegisterHandlerFinder("/shooting_user", h.createShootingUserHandler("/shooting_user"))
	return log_handler.New(fallback.New(handlerFinder, static.NewWithReturnCode("not found", 404)))
}