fake-sms/internal/route/mount.go

34 lines
721 B
Go
Raw Permalink Normal View History

2020-12-21 15:56:56 +01:00
package route
import (
"forge.cadoles.com/Cadoles/fake-sms/internal/config"
"github.com/go-chi/chi"
"gitlab.com/wpetit/goweb/static"
)
func Mount(r *chi.Mux, config *config.Config) error {
r.Group(func(r chi.Router) {
r.Get("/", serveOutboxPage)
r.Delete("/sms", handleClearOutbox)
r.Get("/sms/{id}", serveSMSPage)
r.Delete("/sms/{id}", handleSMSDelete)
})
r.Route("/api", func(r chi.Router) {
r.Route("/v1", func(r chi.Router) {
r.Get("/sms", browseAPIV1SMS)
r.Get("/sms/{id}", serveAPIV1SMS)
// Powow Mock
r.Post("/mock/powow", handlePowowEntrypoint)
2020-12-21 15:56:56 +01:00
})
2020-12-21 15:56:56 +01:00
})
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}