API Implementation, patches
This commit is contained in:
16
api/api.go
16
api/api.go
@ -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)
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package api
|
||||
|
||||
import "net/http"
|
||||
|
||||
func hostsGet(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
Reference in New Issue
Block a user