Exemplo n.º 1
0
func (h *handlerConfiguration) GetHandler() http.Handler {
	logger.Debugf("root: %s", h.documentRoot)
	fileServer := cachingheader.NewCachingHeaderHandler(contenttype.NewContentTypeHandler(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.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("/authentication", h.createAuthenticationHandlerFinder("/authentication"))
	handlerFinder.RegisterHandler("/status", h.handle_errors(booking_status_handler.New()))
	return log_handler.NewLogHandler(fallback.NewFallback(handlerFinder, static.NewHandlerStaticContentReturnCode("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)))
}