Skip to content

Commit

Permalink
feat: add new routes for newservice API
Browse files Browse the repository at this point in the history
- Added GET route for /kuromi/
- Added POST route for /kuromi/
  • Loading branch information
Alonza0314 committed Aug 31, 2024
1 parent daf57a1 commit 7a2d69f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GO_BIN_PATH = bin

VERSION = $(shell git describe --tags)
# VERSION = $(shell git describe --tags)
VERSION = "v1.0.0"
BUILD_TIME = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
COMMIT_HASH = $(shell git submodule status | grep $(GO_SRC_PATH)/$(@F) | awk '{print $$(1)}' | cut -c1-8)
COMMIT_TIME = $(shell git log --pretty="@%at" -1 | xargs date -u +"%Y-%m-%dT%H:%M:%SZ" -d)
Expand Down
37 changes: 37 additions & 0 deletions internal/sbi/api_kuromi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package sbi

import (
"net/http"

"github.com/gin-gonic/gin"
)

func (s *Server) getKuromiRoute() []Route {
return []Route{
{
Name: "Hello KUROMI",

Check failure on line 12 in internal/sbi/api_kuromi.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
Method: http.MethodGet,
Pattern: "/",
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, "Hello Kuromi!")
},
// Use
// curl -X GET http://127.0.0.163:8000/kuromi/ -w "\n"
},
}
}

func (s *Server) postKuromiRoute() []Route {
return []Route{
{
Name: "Big KUROMI",

Check failure on line 27 in internal/sbi/api_kuromi.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
Method: http.MethodPost,
Pattern: "/",
APIFunc: func(c *gin.Context) {
c.String(http.StatusOK, "⣴⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⡷\n⠈⣿⣷⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣿⣿\n⠀⢸⣿⣿⣿⣿⣷⣆⣀⣀⣀⣀⣀⣾⣿⣿⣿⣿⡇\n⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\n⠀⠀⠿⢿⣿⣿⣿⣿⡏⡀⠀⡙⣿⣿⣿⣿⣿⠛\n⠀⠀⠀⣿⣿⣿⡿⠟⠷⣅⣀⠵⠟⢿⣿⣿⣿⡆\n⠀⠀⠀⣿⣿⠏⢲⣤⠀⠀⠀⠀⢠⣶⠙⣿⣿⠃\n⠀⠀⠀⠘⢿⡄⠈⠃⠀⢐⢔⠀⠈⠋⢀⡿⠋\n⠀⠀⠀⢀⢀⣼⣷⣶⣤⣤⣭⣤⣴⣶⣍\n⠀⠀⠀⠈⠈⣈⢰⠿⠛⠉⠉⢻⢇⠆⣁⠁\n⠀⠀⠀⠀⠀⠑⢸⠉⠀⠀⠀⠀⠁⡄⢘⣽⣿\n⠀⠀⠀⠀⠀⠀⡜⠀⠀⢰⡆⠀⠀⠻⠛⠋\n⠀⠀⠀⠀⠀⠀⠑⠒⠒⠈⠈⠒⠒⠊")

Check failure on line 31 in internal/sbi/api_kuromi.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

line is 281 characters (lll)
},
// Use
// curl -X POST http://127.0.0.163:8000/kuromi/ -w "\n"
},
}
}

Check failure on line 37 in internal/sbi/api_kuromi.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
4 changes: 4 additions & 0 deletions internal/sbi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func newRouter(s *Server) *gin.Engine {
spyFamilyGroup := router.Group("/spyfamily")
applyRoutes(spyFamilyGroup, s.getSpyFamilyRoute())

kuroumiGroup := router.Group("/kuromi")
applyRoutes(kuroumiGroup, s.getKuromiRoute())
applyRoutes(kuroumiGroup, s.postKuromiRoute())

return router
}

Expand Down

0 comments on commit 7a2d69f

Please sign in to comment.