Esempio n. 1
0
func NewHandler(documentRoot string, dbPath string) http.Handler {
	logger.Debugf("root: %s", documentRoot)

	entryStorage := stats_entry_storage.New(dbPath, false)
	entryService := stats_entry_service.New(entryStorage)

	fileServer := cachingheader.NewCachingHeaderHandler(contenttype.NewContentTypeHandler(http.FileServer(http.Dir(documentRoot))))
	handlerFinder := part.New("")
	handlerFinder.RegisterHandler("/", fileServer)
	handlerFinder.RegisterHandler("/css", fileServer)
	handlerFinder.RegisterHandler("/js", fileServer)
	handlerFinder.RegisterHandler("/images", fileServer)
	handlerFinder.RegisterHandlerFinder("/entry", createEntryHandlerFinder("/entry", entryService))
	return log_handler.NewLogHandler(fallback.NewFallback(handlerFinder, static.NewHandlerStaticContentReturnCode("not found", 404)))
}
Esempio n. 2
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)))
}