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

mendersoftware / mender-server / 1795862003

01 May 2025 11:44AM UTC coverage: 65.221%. First build
1795862003

Pull #615

gitlab-ci

bahaa-ghazal
feat: Implemented content type checker middleware for gin framework

Ticket: MEN-8327
Changelog: Title
Signed-off-by: Bahaa Aldeen Ghazal <bahaa.ghazal@northern.tech>
Pull Request #615: feat: Implemented content type checker middleware for gin framework

0 of 27 new or added lines in 2 files covered. (0.0%)

31802 of 48760 relevant lines covered (65.22%)

1.37 hits per line

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

69.23
/backend/pkg/rest.utils/utils.go
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
package rest
16

17
import (
18
        "github.com/gin-gonic/gin"
19

20
        "github.com/mendersoftware/mender-server/pkg/requestid"
21
)
22

23
func RenderError(c *gin.Context, code int, err error) {
2✔
24
        ctx := c.Request.Context()
2✔
25
        _ = c.Error(err)
2✔
26
        err = &Error{
2✔
27
                Err:       err.Error(),
2✔
28
                RequestID: requestid.FromContext(ctx),
2✔
29
        }
2✔
30
        c.JSON(code, err)
2✔
31
}
2✔
32

NEW
33
func ApplyMiddlewareToRoutes(middleware gin.HandlerFunc, routes ...gin.IRoutes) {
×
NEW
34
        for _, route := range routes {
×
NEW
35
                route.Use(middleware)
×
NEW
36
        }
×
37
}
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

© 2025 Coveralls, Inc