Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions internal/sbi/api_lab6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package sbi

import (
"net/http"

Check failure on line 4 in internal/sbi/api_lab6.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)

"github.com/gin-gonic/gin"

Check failure on line 6 in internal/sbi/api_lab6.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)
)

// Rutas del nuevo servicio /lab6
func (s *Server) getLab6Route() []Route {
return []Route{

Check failure on line 11 in internal/sbi/api_lab6.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)
{
Name: "Lab6 Info",
Method: http.MethodGet,
Pattern: "/", // -> /lab6/
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "Lab 6 OK",
"author": "Paladinez",
})
},
},
{
Name: "Lab6 Echo",
Method: http.MethodPost,
Pattern: "/echo", // -> /lab6/echo
APIFunc: func(c *gin.Context) {
var body map[string]interface{}

if err := c.BindJSON(&body); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": "invalid JSON body",
})
return
}

c.JSON(http.StatusOK, gin.H{
"message": "Lab 6 echo",
"received": body,
})
},
},
}
}
16 changes: 10 additions & 6 deletions internal/sbi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ func applyRoutes(group *gin.RouterGroup, routes []Route) {
}

func newRouter(s *Server) *gin.Engine {
router := logger_util.NewGinWithLogrus(logger.GinLog)
router := logger_util.NewGinWithLogrus(logger.GinLog)

defaultGroup := router.Group("/default")
applyRoutes(defaultGroup, s.getDefaultRoute())
defaultGroup := router.Group("/default")
applyRoutes(defaultGroup, s.getDefaultRoute())

spyFamilyGroup := router.Group("/spyfamily")
applyRoutes(spyFamilyGroup, s.getSpyFamilyRoute())
spyFamilyGroup := router.Group("/spyfamily")
applyRoutes(spyFamilyGroup, s.getSpyFamilyRoute())

return router
// Nuevo servicio para el Lab 6
lab6Group := router.Group("/lab6")
applyRoutes(lab6Group, s.getLab6Route())

return router
}

func bindRouter(nf app.App, router *gin.Engine, tlsKeyLogPath string) (*http.Server, error) {
Expand Down
Loading