@@ -124,7 +124,7 @@ func main() {
124124 router .GET ("/nothing" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : "Nothing" }) })
125125 router .GET ("/somewhere" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : "Somewhere" }) })
126126 router .GET ("/nowhere" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : "Nowhere" }) })
127-
127+
128128 // Group 2: RESTful API for 'products'
129129 router .GET ("/products" , func (c * gin.Context ) {
130130 products := []Product {
@@ -183,7 +183,7 @@ func main() {
183183 filepath := c .Param ("filepath" )
184184 c .JSON (http .StatusOK , gin.H {"requested_file" : filepath })
185185 })
186-
186+
187187 // Group 4: Different response types
188188 router .GET ("/html" , func (c * gin.Context ) {
189189 c .Data (http .StatusOK , "text/html; charset=utf-8" , []byte ("<h1>This is HTML</h1>" ))
@@ -194,7 +194,7 @@ func main() {
194194 router .GET ("/redirect" , func (c * gin.Context ) {
195195 c .Redirect (http .StatusMovedPermanently , "http://google.com" )
196196 })
197-
197+
198198 // Group 5: More HTTP methods
199199 router .PATCH ("/config" , func (c * gin.Context ) {
200200 var update ConfigUpdate
@@ -222,8 +222,12 @@ func main() {
222222 v2 := router .Group ("/api/v2" )
223223 {
224224 v2 .GET ("/data" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"version" : 2 , "payload" : "new data format" }) })
225- v2 .GET ("/users" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"version" : 2 , "users" : []map [string ]string {{"name" : "gamma" }, {"name" : "delta" }}}) })
226- v2 .POST ("/users" , func (c * gin.Context ) { c .JSON (http .StatusCreated , gin.H {"version" : 2 , "message" : "user successfully registered" }) })
225+ v2 .GET ("/users" , func (c * gin.Context ) {
226+ c .JSON (http .StatusOK , gin.H {"version" : 2 , "users" : []map [string ]string {{"name" : "gamma" }, {"name" : "delta" }}})
227+ })
228+ v2 .POST ("/users" , func (c * gin.Context ) {
229+ c .JSON (http .StatusCreated , gin.H {"version" : 2 , "message" : "user successfully registered" })
230+ })
227231 }
228232
229233 // Group 7: Filler endpoints to reach 63
@@ -241,11 +245,13 @@ func main() {
241245 router .GET ("/anybody" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : "Anybody" }) })
242246 router .GET ("/everybody" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : "Everybody" }) })
243247 router .GET ("/somebody" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : "Somebody" }) })
244- router .PUT ("/user/:id/password" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"message" : fmt .Sprintf ("password for user %s updated" , c .Param ("id" ))}) })
248+ router .PUT ("/user/:id/password" , func (c * gin.Context ) {
249+ c .JSON (http .StatusOK , gin.H {"message" : fmt .Sprintf ("password for user %s updated" , c .Param ("id" ))})
250+ })
245251 router .GET ("/user/:id/profile" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"user_id" : c .Param ("id" ), "profile" : "..." }) })
246252 router .POST ("/events" , func (c * gin.Context ) { c .JSON (http .StatusAccepted , gin.H {"status" : "event received" }) })
247253 router .GET ("/session/info" , func (c * gin.Context ) { c .JSON (http .StatusOK , gin.H {"session_id" : "xyz-123" , "active" : true }) })
248-
254+
249255 // Start the HTTP server on port 8080
250256 router .Run (":8080" )
251- }
257+ }
0 commit comments