API Implementation, patches

This commit is contained in:
Tyler
2021-04-15 00:41:06 -04:00
parent e3958febc7
commit b6efd0df0c
9 changed files with 304 additions and 38 deletions

View File

@ -6,12 +6,22 @@ import (
"net/http"
)
func Start() error {
func New() *API {
r := chi.NewRouter()
r.Use(render.SetContentType(render.ContentTypeJSON))
r.Get("/hosts", hostsGet)
return &API{router: r}
}
return http.ListenAndServe(":8080", 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)
}

View File

@ -1,7 +0,0 @@
package api
import "net/http"
func hostsGet(w http.ResponseWriter, r *http.Request) {
}