27 lines
387 B
Go
27 lines
387 B
Go
package api
|
|
|
|
import (
|
|
"github.com/go-chi/chi"
|
|
"github.com/go-chi/render"
|
|
"net/http"
|
|
)
|
|
|
|
func New() *API {
|
|
r := chi.NewRouter()
|
|
|
|
r.Use(render.SetContentType(render.ContentTypeJSON))
|
|
|
|
return &API{router: r}
|
|
}
|
|
|
|
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)
|
|
} |