parcoursmob/handlers/application/application.go

40 lines
1.1 KiB
Go
Raw Normal View History

package application
import (
"net/http"
"git.coopgo.io/coopgo-apps/parcoursmob/renderer"
"git.coopgo.io/coopgo-apps/parcoursmob/services"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/cache"
"git.coopgo.io/coopgo-platform/emailing"
"github.com/spf13/viper"
)
type ApplicationHandler struct {
config *viper.Viper
Renderer *renderer.Renderer
services *services.ServicesHandler
cache *cache.CacheHandler
emailing *emailing.Mailer
}
func NewApplicationHandler(cfg *viper.Viper, svc *services.ServicesHandler, cache *cache.CacheHandler, emailing *emailing.Mailer) (*ApplicationHandler, error) {
templates_root := cfg.GetString("templates.root")
renderer := renderer.NewRenderer(cfg, templates_root)
return &ApplicationHandler{
config: cfg,
Renderer: renderer,
services: svc,
cache: cache,
emailing: emailing,
}, nil
}
func (h *ApplicationHandler) NotFound(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}
func (h *ApplicationHandler) templateFile(file string) string {
return h.config.GetString("templates.root") + file
}