fake-smtp/internal/route/mount.go

32 lines
807 B
Go
Raw Permalink Normal View History

2020-04-17 17:53:01 +02:00
package route
import (
"forge.cadoles.com/wpetit/fake-smtp/internal/config"
2024-02-27 17:26:32 +01:00
"github.com/go-chi/chi/v5"
2020-04-17 17:53:01 +02:00
"gitlab.com/wpetit/goweb/static"
)
func Mount(r *chi.Mux, config *config.Config) error {
r.Group(func(r chi.Router) {
r.Get("/", serveInboxPage)
r.Delete("/emails", handleClearInbox)
r.Get("/emails/{id}", serveEmailPage)
r.Get("/emails/{id}/html", serveEmailHTMLContent)
r.Get("/emails/{id}/attachments/{attachmendIndex}", serveEmailAttachment)
r.Delete("/emails/{id}", handleEmailDelete)
})
2020-11-03 11:49:31 +01:00
r.Route("/api", func(r chi.Router) {
r.Route("/v1", func(r chi.Router) {
r.Get("/emails", browseAPIV1Emails)
r.Get("/emails/{id}", serveAPIV1Email)
})
})
2020-04-17 17:53:01 +02:00
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}