parent
							
								
									db1ac7ffd6
								
							
						
					
					
						commit
						2282efa3e9
					
				|  | @ -99,14 +99,23 @@ func setEntityStateHandler(w http.ResponseWriter, r *http.Request) { | |||
| 	logRequest(w, r) | ||||
| 	entityId := chi.URLParam(r, "entityId") | ||||
| 	service := chi.URLParam(r, "service") | ||||
| 	domain := r.URL.Query().Get("domain") | ||||
| 
 | ||||
| 	var extras map[string]any | ||||
| 	err := render.DecodeJSON(r.Body, &extras) | ||||
| 	var haErr error | ||||
| 	if err == nil && len(extras) > 0 { | ||||
| 		haErr = haClient.CallService(entityId, service, extras) | ||||
| 		if domain != "" { | ||||
| 			haErr = haClient.CallServiceManual(domain, entityId, service, extras) | ||||
| 		} else { | ||||
| 			haErr = haClient.CallService(entityId, service, extras) | ||||
| 		} | ||||
| 	} else { | ||||
| 		haErr = haClient.CallService(entityId, service) | ||||
| 		if domain != "" { | ||||
| 			haErr = haClient.CallServiceManual(domain, entityId, service) | ||||
| 		} else { | ||||
| 			haErr = haClient.CallService(entityId, service) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if haErr != nil { | ||||
|  |  | |||
|  | @ -70,7 +70,12 @@ func (c *HatsClient) CallService(entityId string, service string, extras ...map[ | |||
| 		data := map[string]interface{}{} | ||||
| 		for _, extra := range extras { | ||||
| 			for k, v := range extra { | ||||
| 				data[k] = v | ||||
| 				switch k { | ||||
| 				case "domain": | ||||
| 					req.SetQueryParam(k, fmt.Sprintf("%v", v)) | ||||
| 				default: | ||||
| 					data[k] = v | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		req.SetBody(data) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue