qa: Use gin

This commit is contained in:
nemunaire 2022-11-06 16:36:31 +01:00
commit abdf146fea
13 changed files with 587 additions and 369 deletions

View file

@ -1,13 +1,24 @@
package api
import (
"github.com/julienschmidt/httprouter"
"net/http"
"github.com/gin-gonic/gin"
)
func init() {
router.GET("/api/version", apiHandler(showVersion))
func declareVersionRoutes(router *gin.RouterGroup) {
router.GET("/version", showVersion)
}
func showVersion(u QAUser, _ httprouter.Params, body []byte) (interface{}, error) {
return map[string]interface{}{"version": 0.1, "auth": u}, nil
func showVersion(c *gin.Context) {
teamid := c.MustGet("LoggedTeam").(int64)
ficteam := c.MustGet("LoggedUser").(string)
c.JSON(http.StatusOK, gin.H{
"version": 0.2,
"auth": map[string]interface{}{
"name": ficteam,
"id_team": teamid,
},
})
}