fake-smtp/internal/route/mount.go
2020-04-18 23:15:21 +02:00

25 lines
637 B
Go

package route
import (
"forge.cadoles.com/wpetit/fake-smtp/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("/", 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)
})
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}