diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2025-08-23 22:29:28 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2025-08-23 22:29:28 +0100 |
| commit | ecc6a55aba7bb35fc778e7a53848396b88214151 (patch) | |
| tree | 1b37a2dc5f4594155114da1ae0c4529d20a4c548 /api/router.go | |
| parent | 8f7dec8ba6b2f9bde01afd0a110596ebbd43e0ed (diff) | |
Add multiple conferences feature
Diffstat (limited to 'api/router.go')
| -rw-r--r-- | api/router.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/api/router.go b/api/router.go index 38e67e6..af52785 100644 --- a/api/router.go +++ b/api/router.go @@ -7,9 +7,9 @@ import ( "github.com/LMBishop/confplanner/api/middleware" "github.com/LMBishop/confplanner/pkg/auth" "github.com/LMBishop/confplanner/pkg/calendar" + "github.com/LMBishop/confplanner/pkg/conference" "github.com/LMBishop/confplanner/pkg/favourites" "github.com/LMBishop/confplanner/pkg/ical" - "github.com/LMBishop/confplanner/pkg/schedule" "github.com/LMBishop/confplanner/pkg/session" "github.com/LMBishop/confplanner/pkg/user" ) @@ -17,7 +17,7 @@ import ( type ApiServices struct { UserService user.Service FavouritesService favourites.Service - ScheduleService schedule.Service + ConferenceService conference.Service CalendarService calendar.Service IcalService ical.Service SessionService session.Service @@ -26,6 +26,7 @@ type ApiServices struct { func NewServer(apiServices ApiServices, baseURL string) *http.ServeMux { mustAuthenticate := middleware.MustAuthenticate(apiServices.UserService, apiServices.SessionService) + admin := middleware.MustAuthoriseAdmin(apiServices.UserService, apiServices.SessionService) mux := http.NewServeMux() @@ -34,12 +35,15 @@ func NewServer(apiServices ApiServices, baseURL string) *http.ServeMux { mux.HandleFunc("POST /login/{provider}", handlers.Login(apiServices.AuthService, apiServices.SessionService)) mux.HandleFunc("POST /logout", mustAuthenticate(handlers.Logout(apiServices.SessionService))) - mux.HandleFunc("GET /favourites", mustAuthenticate(handlers.GetFavourites(apiServices.FavouritesService))) + mux.HandleFunc("GET /conference", mustAuthenticate(handlers.GetConferences(apiServices.ConferenceService))) + mux.HandleFunc("GET /conference/{id}", mustAuthenticate(handlers.GetSchedule(apiServices.ConferenceService))) + mux.HandleFunc("POST /conference", mustAuthenticate(admin(handlers.CreateConference(apiServices.ConferenceService)))) + mux.HandleFunc("DELETE /conference", mustAuthenticate(admin(handlers.DeleteConference(apiServices.ConferenceService)))) + + mux.HandleFunc("GET /favourites/{id}", mustAuthenticate(handlers.GetFavourites(apiServices.FavouritesService))) mux.HandleFunc("POST /favourites", mustAuthenticate(handlers.CreateFavourite(apiServices.FavouritesService))) mux.HandleFunc("DELETE /favourites", mustAuthenticate(handlers.DeleteFavourite(apiServices.FavouritesService))) - mux.HandleFunc("GET /schedule", mustAuthenticate(handlers.GetSchedule(apiServices.ScheduleService))) - mux.HandleFunc("GET /calendar", mustAuthenticate(handlers.GetCalendar(apiServices.CalendarService, baseURL))) mux.HandleFunc("POST /calendar", mustAuthenticate(handlers.CreateCalendar(apiServices.CalendarService, baseURL))) mux.HandleFunc("DELETE /calendar", mustAuthenticate(handlers.DeleteCalendar(apiServices.CalendarService))) |
