• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alimitedgroup / MVP / 13785092874

11 Mar 2025 09:52AM UTC coverage: 34.463% (+27.7%) from 6.719%
13785092874

Pull #16

github

web-flow
Merge cd7bbf9ec into c70df8f01
Pull Request #16: Codifica iniziale del servizio `api-gateway`

131 of 307 new or added lines in 11 files covered. (42.67%)

10 existing lines in 1 file now uncovered.

183 of 531 relevant lines covered (34.46%)

1.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/srv/api_gateway/controller/http_handler.go
1
package controller
2

3
import (
4
        "github.com/alimitedgroup/MVP/srv/api_gateway/business"
5
        "github.com/gin-gonic/gin"
6
        "strings"
7
)
8

9
type HTTPHandler struct {
10
        Engine             *gin.Engine
11
        ApiGroup           *gin.RouterGroup
12
        AuthenticatedGroup *gin.RouterGroup
13
}
14

NEW
15
func NewHTTPHandler(b *business.Business) *HTTPHandler {
×
NEW
16
        gin.SetMode(gin.DebugMode)
×
NEW
17

×
NEW
18
        r := gin.New()
×
NEW
19
        _ = r.SetTrustedProxies(nil)
×
NEW
20
        r.Use(gin.Recovery())
×
NEW
21
        api := r.Group("/api/v1")
×
NEW
22
        authenticated := r.Group("/api/v1")
×
NEW
23
        authenticated.Use(Authentication(b))
×
NEW
24

×
NEW
25
        return &HTTPHandler{r, api, authenticated}
×
NEW
26
}
×
27

NEW
28
func Authentication(b *business.Business) gin.HandlerFunc {
×
NEW
29
        return func(ctx *gin.Context) {
×
NEW
30
                auth, found := strings.CutPrefix(ctx.GetHeader("Authorization"), "Bearer ")
×
NEW
31
                if !found {
×
NEW
32
                        ctx.AbortWithStatusJSON(401, gin.H{"error": "unauthorized", "message": "No token provided"})
×
NEW
33
                        return
×
NEW
34
                }
×
NEW
35
                data, err := b.ValidateToken(auth)
×
NEW
36
                if err != nil {
×
NEW
37
                        ctx.AbortWithStatusJSON(401, gin.H{"error": "unauthorized", "message": err.Error()})
×
NEW
38
                        return
×
NEW
39
                }
×
40

NEW
41
                ctx.Set("user_data", data)
×
NEW
42
                ctx.Next()
×
43
        }
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc