From dd665d9443ea1c3f631c94454482f2f9ca6220f8 Mon Sep 17 00:00:00 2001 From: minie4 Date: Wed, 28 Feb 2024 11:03:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Make=20JSON=20keys=20lowercase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.go | 22 +++++++++++----------- routing.go | 34 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/api.go b/api.go index 2e89a44..f2403d9 100644 --- a/api.go +++ b/api.go @@ -59,10 +59,10 @@ func handleGetPort(c *gin.Context) { } type CreatePortRequest struct { - Name string - Backend string - Channels uint8 - Type string + Name string `json:"name"` + Backend string `json:"backend"` + Channels uint8 `json:"channels"` + Type string `json:"type"` } func handleCreatePort(c *gin.Context) { @@ -159,9 +159,9 @@ func handleGetState(c *gin.Context) { } type SetPortRequest struct { - Mute *bool - Volume *float32 - Balance *float32 + Mute *bool `json:"mute"` + Volume *float32 `json:"volume"` + Balance *float32 `json:"balance"` } func handleSetState(c *gin.Context) { @@ -203,7 +203,7 @@ func setState(id string, body SetPortRequest) (gin.H, gin.H) { } type CreateRouteRequest struct { - To string + To string `json:"to"` } func handleCreateRoute(c *gin.Context) { @@ -240,9 +240,9 @@ func createRoute(id string, body CreateRouteRequest) gin.H { } type SetRouteRequest struct { - Mute *bool - Volume *float32 - Balance *float32 + Mute *bool `json:"mute"` + Volume *float32 `json:"volume"` + Balance *float32 `json:"balance"` } func handleSetRoute(c *gin.Context) { diff --git a/routing.go b/routing.go index 5b86b16..d252a7e 100644 --- a/routing.go +++ b/routing.go @@ -7,35 +7,35 @@ import ( ) type PortState struct { - Mute bool - Volume float32 - Balance float32 + Mute bool `json:"mute"` + Volume float32 `json:"volume"` + Balance float32 `json:"balance"` } type PortProperties struct { - Backend string - Channels uint8 + Backend string `json:"backend"` + Channels uint8 `json:"channels"` } type PortRoute struct { - ToUUID string - Mute bool - Volume float32 - Balance float32 + ToUUID string `json:"toUUID"` + Mute bool `json:"mute"` + Volume float32 `json:"volume"` + Balance float32 `json:"balance"` } type Port struct { - UUID string - Name string - Properties PortProperties - State PortState - Route []PortRoute + UUID string `json:"UUID"` + Name string `json:"name"` + Properties PortProperties `json:"properties"` + State PortState `json:"state"` + Route []PortRoute `json:"route"` object []*jack.Port } var portConfig struct { - Input []Port - Output []Port + Input []Port `json:"input"` + Output []Port `json:"output"` } var portsInited bool = false @@ -124,7 +124,7 @@ func addToBuffer(src *[]jack.AudioSample, dst *[]jack.AudioSample, volume float3 } func multiplyBuffer(dst *[]jack.AudioSample, factor float32) { - for i, _ := range *dst { + for i := range *dst { (*dst)[i] *= jack.AudioSample(factor) } }