parcoursmob/servers/web/api/handler.go

37 lines
1.2 KiB
Go

package api
import (
"net/http"
"git.coopgo.io/coopgo-apps/parcoursmob/core/application"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/cache"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/geo"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/identification"
cacheStorage "git.coopgo.io/coopgo-apps/parcoursmob/core/utils/storage"
"github.com/spf13/viper"
)
type Handler struct {
config *viper.Viper
idp *identification.IdentificationProvider
applicationHandler *application.ApplicationHandler
cacheService *cache.CacheService
geoService *geo.GeoService
}
func NewHandler(cfg *viper.Viper, idp *identification.IdentificationProvider, appHandler *application.ApplicationHandler, cacheHandler cacheStorage.CacheHandler) *Handler {
cacheService := cache.NewCacheService(cacheHandler)
geoService := geo.NewGeoService(cfg.GetString("geo.pelias.url"))
return &Handler{
config: cfg,
idp: idp,
applicationHandler: appHandler,
cacheService: cacheService,
geoService: geoService,
}
}
func (h *Handler) NotFound(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}