fake-sms/internal/route/mount.go

30 lines
654 B
Go
Raw 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)
})
})
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}