Newer
Older
_ "forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/docs"
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/auth"
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/monthlyNews"
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/monthlyReport"
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/poll"
// @title Backoffice API
// @version 1.0
// @description This is a sample service for managing newsletters for Ecolyo
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.email rpailharey@grandlyon.com
// @host localhost:1443
// @BasePath /
func CreateRootMux(staticDir string) RootMux {
r.HandleFunc("/OAuth2Login", m.HandleOAuth2Login)
r.Handle("/OAuth2Callback", m.HandleOAuth2Callback())
r.HandleFunc("/Logout", m.HandleLogout)
r.Handle("/api/common/WhoAmI", auth.ValidateAuthMiddleware(auth.WhoAmI(), []string{"*"}, false))
r.HandleFunc("/api/common/monthlyReport", monthlyReport.GetMostRecentMonthlyReport).Methods(http.MethodGet)
r.HandleFunc("/api/common/monthlyReport/{year}/{month}", monthlyReport.GetSingleMonthlyReport).Methods(http.MethodGet)
apiAdmin := r.PathPrefix("/api/admin").Subrouter()
apiAdmin.Use(auth.AdminAuthMiddleware)
apiAdmin.HandleFunc("/monthlyNews", monthlyNews.GetAllMonthlyNews).Methods(http.MethodGet)
apiAdmin.HandleFunc("/monthlyNews/{year}/{month}", monthlyNews.GetSingleMonthlyNews).Methods(http.MethodGet)
apiAdmin.HandleFunc("/monthlyNews", monthlyNews.AddMonthlyNews).Methods(http.MethodPost)
apiAdmin.HandleFunc("/monthlyNews", monthlyNews.UpdateMonthlyNews).Methods(http.MethodPut)
apiAdmin.HandleFunc("/monthlyNews/{year}/{month}", monthlyNews.DeleteMonthlyNews).Methods(http.MethodDelete)
apiAdmin.HandleFunc("/poll", poll.GetAllPolls).Methods(http.MethodGet)
apiAdmin.HandleFunc("/poll/{year}/{month}", poll.GetSinglePoll).Methods(http.MethodGet)
apiAdmin.HandleFunc("/poll", poll.AddPoll).Methods(http.MethodPost)
apiAdmin.HandleFunc("/poll", poll.UpdatePoll).Methods(http.MethodPut)
apiAdmin.HandleFunc("/poll/{year}/{month}", poll.DeletePoll).Methods(http.MethodDelete)
// Swagger
r.PathPrefix("/swagger").Handler(httpSwagger.WrapHandler)
// Redirect route
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {})