Skip to content
Open
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
26 changes: 26 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Go CI

on:
push:
branches:
- main
- feature/github-actions-ci
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Run Go tests
run: go test ./...
56 changes: 56 additions & 0 deletions internal/sbi/api_student.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package sbi

import (
"net/http"

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

// Estructura para el cuerpo del POST
type StudentRequest struct {
Name string `json:"name"`

Check failure on line 11 in internal/sbi/api_student.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)
CodeID string `json:"code_id"`
}

// Rutas del grupo /student
func (s *Server) getStudentRoute() []Route {
return []Route{
{
Name: "GetStudent",
Method: "GET",
Pattern: "/",
APIFunc: GetStudent,
},
{
Name: "PostStudent",
Method: "POST",
Pattern: "/",
APIFunc: PostStudent,
},
}
}

// Handler para GET /student/
func GetStudent(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "Hello from Student API!",
})
}

// Handler para POST /student/
func PostStudent(c *gin.Context) {
var req StudentRequest

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

c.JSON(http.StatusOK, gin.H{
"message": "Student registered successfully",
"name": req.Name,
"code_id": req.CodeID,
})
}
2 changes: 2 additions & 0 deletions internal/sbi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func newRouter(s *Server) *gin.Engine {
spyFamilyGroup := router.Group("/spyfamily")
applyRoutes(spyFamilyGroup, s.getSpyFamilyRoute())

studentGroup := router.Group("/student")
applyRoutes(studentGroup, s.getStudentRoute())
return router
}

Expand Down
Loading