Skip to content

Commit

Permalink
fix: resolve gci issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntu committed Sep 23, 2024
1 parent e9c3fb2 commit c2b37fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions internal/sbi/api_sao.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package sbi

import (
"net/http"
"strings"

"github.com/gin-gonic/gin"

"strings"
)

type SAOCharacterList struct {
Expand Down Expand Up @@ -33,7 +32,7 @@ func (s *Server) getSAORoute() []Route {
Method: http.MethodGet,
Pattern: "/list",
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, "SAO Character List : " + strings.Join(list.Characters, ", "))
c.JSON(http.StatusOK, "SAO Character List : "+strings.Join(list.Characters, ", "))
},
// Use
// curl -X GET http://127.0.0.163:8000/sao/list -w "\n"
Expand All @@ -51,22 +50,18 @@ func (s *Server) postSAORoute() []Route {
var character struct {
Name string `json:"name"`
}

err := c.ShouldBindJSON(&character)

if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}

list.Characters = append(list.Characters, character.Name)
c.JSON(http.StatusOK, "Hello " + character.Name + "!")
c.JSON(http.StatusOK, "Hello "+character.Name+"!")
},
// Use
// curl -X POST http://127.0.0.163:8000/sao/character -d '{"name": "Kirito"}' -w "\n"
},
}
}



2 changes: 1 addition & 1 deletion internal/sbi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newRouter(s *Server) *gin.Engine {
saoGroup := router.Group("/sao")
applyRoutes(saoGroup, s.getSAORoute())
applyRoutes(saoGroup, s.postSAORoute())

return router
}

Expand Down

0 comments on commit c2b37fe

Please sign in to comment.