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)
|
2020-12-22 15:00:42 +01:00
|
|
|
|
|
|
|
// Powow Mock
|
|
|
|
r.Post("/mock/powow", handlePowowEntrypoint)
|
2020-12-21 15:56:56 +01:00
|
|
|
})
|
2020-12-22 15:00:42 +01:00
|
|
|
|
2020-12-21 15:56:56 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
notFoundHandler := r.NotFoundHandler()
|
|
|
|
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|