refactor: Add Go 1.22 HTTP method matching
This commit is contained in:
parent
bd94b295ac
commit
74a8db7d2b
3 changed files with 7 additions and 15 deletions
10
main.go
10
main.go
|
|
@ -51,20 +51,20 @@ func main() {
|
|||
}(&conf.Response)
|
||||
|
||||
// Register HTTP handlers
|
||||
http.HandleFunc("/",
|
||||
http.HandleFunc("GET /{$}",
|
||||
handlers.Root(&conf.Response),
|
||||
)
|
||||
http.HandleFunc("/state/open",
|
||||
http.HandleFunc("PUT /state/open",
|
||||
handlers.StateOpen(conf.Credentials, conf.Dynamic.State.Open.AllowedCredentials, &conf.Response.State),
|
||||
)
|
||||
// Register handlers for environmental sensors
|
||||
// Register handler for environmental sensors
|
||||
for sensorType, envSensorConfigs := range conf.Dynamic.Sensors {
|
||||
for i, envSensorConfig := range envSensorConfigs {
|
||||
urlPath := util.GetSensorURLPath(
|
||||
urlPattern := "PUT " + util.GetSensorURLPath(
|
||||
sensorType, envSensorConfig.SensorData.Location, envSensorConfig.SensorData.Name,
|
||||
)
|
||||
http.HandleFunc(
|
||||
urlPath,
|
||||
urlPattern,
|
||||
handlers.EnvironmentSensor(
|
||||
conf.Credentials, envSensorConfig.AllowedCredentials, &conf.Response.Sensors[sensorType][i],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue