Skip to content

Commit

Permalink
Update babyapi@v0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmclean committed Aug 10, 2024
1 parent e25ab3d commit db121ac
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion garden-app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.3
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/ajg/form v1.5.1
github.com/calvinmclean/babyapi v0.21.0
github.com/calvinmclean/babyapi v0.22.0
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/go-chi/render v1.0.3
github.com/go-co-op/gocron v1.35.2
Expand Down
4 changes: 2 additions & 2 deletions garden-app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/calvinmclean/babyapi v0.21.0 h1:rRakzuDY1ZTz92QEZmfWMshTDMaBwgBYOp6nTF3D4A0=
github.com/calvinmclean/babyapi v0.21.0/go.mod h1:zSNiVRsL3DBPOMkXxMJOTFNtzU1ZrPFKD0LFx2JVp4I=
github.com/calvinmclean/babyapi v0.22.0 h1:g27F4DFdGeQfI97Pn+vGZtRkvR/RdWwqq2OMgSO7BAk=
github.com/calvinmclean/babyapi v0.22.0/go.mod h1:zSNiVRsL3DBPOMkXxMJOTFNtzU1ZrPFKD0LFx2JVp4I=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
4 changes: 2 additions & 2 deletions garden-app/server/garden.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewGardenAPI() *GardensAPI {
}
}))

api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(r *http.Request, g *pkg.Garden) (render.Renderer, *babyapi.ErrResponse) {
api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(_ http.ResponseWriter, r *http.Request, g *pkg.Garden) (render.Renderer, *babyapi.ErrResponse) {
switch r.URL.Query().Get("type") {
case "edit_modal":
return api.gardenModalRenderer(r.Context(), g), nil
Expand Down Expand Up @@ -196,7 +196,7 @@ func (api *GardensAPI) onCreateOrUpdate(_ http.ResponseWriter, r *http.Request,
// gardenAction reads a GardenAction request and uses it to execute one of the actions
// that is available to run against a Zone. This one endpoint is used for all the different
// kinds of actions so the action information is carried in the request body
func (api *GardensAPI) gardenAction(r *http.Request, garden *pkg.Garden) (render.Renderer, *babyapi.ErrResponse) {
func (api *GardensAPI) gardenAction(_ http.ResponseWriter, r *http.Request, garden *pkg.Garden) (render.Renderer, *babyapi.ErrResponse) {
logger := babyapi.GetLoggerFromContext(r.Context())
logger.Info("received request to execute GardenAction")

Expand Down
2 changes: 1 addition & 1 deletion garden-app/server/garden_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (agr AllGardensResponse) Render(w http.ResponseWriter, r *http.Request) err
return agr.ResourceList.Render(w, r)
}

func (agr AllGardensResponse) HTML(r *http.Request) string {
func (agr AllGardensResponse) HTML(_ http.ResponseWriter, r *http.Request) string {

Check warning on line 161 in garden-app/server/garden_responses.go

View check run for this annotation

Codecov / codecov/patch

garden-app/server/garden_responses.go#L161

Added line #L161 was not covered by tests
slices.SortFunc(agr.Items, func(g *GardenResponse, h *GardenResponse) int {
return strings.Compare(g.Name, h.Name)
})
Expand Down
2 changes: 1 addition & 1 deletion garden-app/server/water_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewWaterSchedulesAPI() *WaterSchedulesAPI {
}
}))

api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(r *http.Request, ws *pkg.WaterSchedule) (render.Renderer, *babyapi.ErrResponse) {
api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(_ http.ResponseWriter, r *http.Request, ws *pkg.WaterSchedule) (render.Renderer, *babyapi.ErrResponse) {
switch r.URL.Query().Get("type") {
case "edit_modal":
return api.waterScheduleModalRenderer(r.Context(), ws), nil
Expand Down
2 changes: 1 addition & 1 deletion garden-app/server/water_schedule_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (aws AllWaterSchedulesResponse) Render(w http.ResponseWriter, r *http.Reque
return aws.ResourceList.Render(w, r)
}

func (aws AllWaterSchedulesResponse) HTML(r *http.Request) string {
func (aws AllWaterSchedulesResponse) HTML(_ http.ResponseWriter, r *http.Request) string {

Check warning on line 115 in garden-app/server/water_schedule_responses.go

View check run for this annotation

Codecov / codecov/patch

garden-app/server/water_schedule_responses.go#L115

Added line #L115 was not covered by tests
slices.SortFunc(aws.Items, func(w *WaterScheduleResponse, x *WaterScheduleResponse) int {
return strings.Compare(w.Name, x.Name)
})
Expand Down
2 changes: 1 addition & 1 deletion garden-app/server/weather_client_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (aws AllWeatherClientsResponse) Render(w http.ResponseWriter, r *http.Reque
return aws.ResourceList.Render(w, r)
}

func (aws AllWeatherClientsResponse) HTML(r *http.Request) string {
func (aws AllWeatherClientsResponse) HTML(_ http.ResponseWriter, r *http.Request) string {

Check warning on line 54 in garden-app/server/weather_client_responses.go

View check run for this annotation

Codecov / codecov/patch

garden-app/server/weather_client_responses.go#L54

Added line #L54 was not covered by tests
slices.SortFunc(aws.Items, func(w *WeatherClientResponse, x *WeatherClientResponse) int {
return strings.Compare(w.Type, x.Type)
})
Expand Down
2 changes: 1 addition & 1 deletion garden-app/server/weather_clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewWeatherClientsAPI() *WeatherClientsAPI {
}
}))

api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(r *http.Request, wc *weather.Config) (render.Renderer, *babyapi.ErrResponse) {
api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(_ http.ResponseWriter, r *http.Request, wc *weather.Config) (render.Renderer, *babyapi.ErrResponse) {
switch r.URL.Query().Get("type") {
case "edit_modal":
return weatherClientModalTemplate.Renderer(wc), nil
Expand Down
6 changes: 3 additions & 3 deletions garden-app/server/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewZonesAPI() *ZonesAPI {
}
}))

api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(r *http.Request, z *pkg.Zone) (render.Renderer, *babyapi.ErrResponse) {
api.AddCustomIDRoute(http.MethodGet, "/components", api.GetRequestedResourceAndDo(func(_ http.ResponseWriter, r *http.Request, z *pkg.Zone) (render.Renderer, *babyapi.ErrResponse) {
switch r.URL.Query().Get("type") {
case "edit_modal":
return api.createModal(r, z)
Expand Down Expand Up @@ -145,7 +145,7 @@ func (api *ZonesAPI) createModal(r *http.Request, zone *pkg.Zone) (render.Render
// zoneAction reads a ZoneAction request and uses it to execute one of the actions
// that is available to run against a Zone. This one endpoint is used for all the different
// kinds of actions so the action information is carried in the request body
func (api *ZonesAPI) zoneAction(r *http.Request, zone *pkg.Zone) (render.Renderer, *babyapi.ErrResponse) {
func (api *ZonesAPI) zoneAction(_ http.ResponseWriter, r *http.Request, zone *pkg.Zone) (render.Renderer, *babyapi.ErrResponse) {
logger := babyapi.GetLoggerFromContext(r.Context())
logger.Info("received request to execute ZoneAction")

Expand Down Expand Up @@ -281,7 +281,7 @@ func limitQueryParam(r *http.Request) (uint64, error) {
}

// WaterHistory responds with the Zone's recent water events read from InfluxDB
func (api *ZonesAPI) waterHistory(r *http.Request, zone *pkg.Zone) (render.Renderer, *babyapi.ErrResponse) {
func (api *ZonesAPI) waterHistory(_ http.ResponseWriter, r *http.Request, zone *pkg.Zone) (render.Renderer, *babyapi.ErrResponse) {
logger := babyapi.GetLoggerFromContext(r.Context())
logger.Info("received request to get Zone water history")

Expand Down
4 changes: 2 additions & 2 deletions garden-app/server/zone_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (api *ZonesAPI) NewZoneResponse(zone *pkg.Zone, links ...Link) *ZoneRespons
}
}

func (zr *ZoneResponse) HTML(r *http.Request) string {
func (zr *ZoneResponse) HTML(_ http.ResponseWriter, r *http.Request) string {

Check warning on line 40 in garden-app/server/zone_responses.go

View check run for this annotation

Codecov / codecov/patch

garden-app/server/zone_responses.go#L40

Added line #L40 was not covered by tests
// ignoring errors here since this can only be reached for a valid request
timeRange, _ := rangeQueryParam(r)
limit, _ := limitQueryParam(r)
Expand Down Expand Up @@ -162,7 +162,7 @@ func (azr AllZonesResponse) Render(w http.ResponseWriter, r *http.Request) error
return azr.ResourceList.Render(w, r)
}

func (azr AllZonesResponse) HTML(r *http.Request) string {
func (azr AllZonesResponse) HTML(_ http.ResponseWriter, r *http.Request) string {

Check warning on line 165 in garden-app/server/zone_responses.go

View check run for this annotation

Codecov / codecov/patch

garden-app/server/zone_responses.go#L165

Added line #L165 was not covered by tests
slices.SortFunc(azr.Items, func(z *ZoneResponse, zz *ZoneResponse) int {
return strings.Compare(z.Name, zz.Name)
})
Expand Down

0 comments on commit db121ac

Please sign in to comment.