parcoursmob/handlers/api/protected/protected.go

33 lines
894 B
Go

package protected
import (
"net/http"
"git.coopgo.io/coopgo-apps/parcoursmob/services"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
cache "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
"github.com/spf13/viper"
)
type ProtectedAPIHandler struct {
ApiKey string
idp *identification.IdentificationProvider
config *viper.Viper
services *services.ServicesHandler
cache cache.CacheHandler
}
func NewProtectedAPIHandler(cfg *viper.Viper, idp *identification.IdentificationProvider, svc *services.ServicesHandler, cache cache.CacheHandler) (*ProtectedAPIHandler, error) {
return &ProtectedAPIHandler{
ApiKey: cfg.GetString("services.api.api_key"),
idp: idp,
config: cfg,
services: svc,
cache: cache,
}, nil
}
func (h *ProtectedAPIHandler) NotFound(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}