API Implementation, patches

This commit is contained in:
Tyler committed 2021-04-15 00:41:06 -04:00
1 parent e3958febc7
commit b6efd0df0c
9 files changed
+304 -38

No files matched your search

+13 -3
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)
}
-7
View File
@@ -1,7 +0,0 @@
package api
import "net/http"
func hostsGet(w http.ResponseWriter, r *http.Request) {
}