godns/api/api.go

27 lines
387 B
Go
Raw Normal View History

package api
import (
"github.com/go-chi/chi"
"github.com/go-chi/render"
"net/http"
)
2021-04-15 04:41:06 +00:00
func New() *API {
r := chi.NewRouter()
r.Use(render.SetContentType(render.ContentTypeJSON))
2021-04-15 04:41:06 +00:00
return &API{router: r}
}
2021-04-15 04:41:06 +00:00
type API struct {
router chi.Router
}
func (a *API) Router() chi.Router {
return a.router
}
func (a *API) Start() error {
return http.ListenAndServe(":8080", a.router)
}