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

mendersoftware / mender-server / 1978029483

11 Aug 2025 02:15PM UTC coverage: 65.755% (+0.3%) from 65.495%
1978029483

Pull #860

gitlab-ci

kjaskiewiczz
docs(useradm): move API specification to single file

Changelog: Title
Ticket: QA-1094
Signed-off-by: Krzysztof Jaskiewicz <krzysztof.jaskiewicz@northern.tech>
Pull Request #860: docs(useradm): move API specification to single file

29261 of 44500 relevant lines covered (65.76%)

1.44 hits per line

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

70.59
/backend/pkg/requestsize/middleware.go
1
package requestsize
2

3
import (
4
        "net/http"
5

6
        "github.com/gin-gonic/gin"
7

8
        "github.com/mendersoftware/mender-server/pkg/rest.utils"
9
)
10

11
func Middleware(size int64) gin.HandlerFunc {
7✔
12
        if size < 0 {
7✔
13
                panic("requestsize Middleware initialized with negativ size")
×
14
        }
15
        tooLargeErr := http.MaxBytesError{
7✔
16
                Limit: size,
7✔
17
        }
7✔
18
        return func(c *gin.Context) {
14✔
19
                // if the Content-Length in header and is greater than size limit
7✔
20
                if c.Request.ContentLength > int64(size) {
7✔
21
                        rest.RenderError(c, http.StatusRequestEntityTooLarge, &tooLargeErr)
×
22
                        c.Abort()
×
23
                        return
×
24
                }
×
25
                // wrapping a nil body with MaxBytesReader causes a nil pointer dereference panic
26
                // when calling c.ShouldBindJSON()
27
                if c.Request.Body != nil {
14✔
28
                        c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, size)
7✔
29
                }
7✔
30

31
                c.Next()
7✔
32
        }
33
}
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