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

mendersoftware / reporting / 732508278

pending completion
732508278

Pull #87

gitlab-ci

Fabio Tranchitella
refac: rename internal search end-point to `/tenants/{tenant_id}/devices/search`
Pull Request #87: MEN-5930: index device deployment objects

331 of 402 new or added lines in 12 files covered. (82.34%)

135 existing lines in 5 files now uncovered.

2196 of 2600 relevant lines covered (84.46%)

17.72 hits per line

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

80.77
/api/http/utils.go
1
// Copyright 2022 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 http
16

17
import (
18
        "fmt"
19
        "net/url"
20

21
        "github.com/gin-gonic/gin"
22
)
23

24
func pageLinkHdrs(c *gin.Context, page, perPage, total int) {
27✔
25
        url := &url.URL{
27✔
26
                Path:     c.Request.URL.Path,
27✔
27
                RawQuery: c.Request.URL.RawQuery,
27✔
28
                Fragment: c.Request.URL.Fragment,
27✔
29
        }
27✔
30

27✔
31
        query := url.Query()
27✔
32

27✔
33
        query.Set("page", "1")
27✔
34
        query.Set("per_page", fmt.Sprintf("%d", perPage))
27✔
35
        url.RawQuery = query.Encode()
27✔
36
        Link := fmt.Sprintf(`<%s>;rel="first"`, url.String())
27✔
37
        // Previous page
27✔
38
        if page > 1 {
31✔
39
                query.Set("page", fmt.Sprintf("%d", page-1))
4✔
40
                url.RawQuery = query.Encode()
4✔
41
                Link = fmt.Sprintf(`%s, <%s>;rel="previous"`, Link, url.String())
4✔
42
        }
4✔
43

44
        // Next page
45
        if total > (perPage*page - 1) {
27✔
NEW
46
                query.Set("page", fmt.Sprintf("%d", page+1))
×
NEW
47
                url.RawQuery = query.Encode()
×
NEW
48
                Link = fmt.Sprintf(`%s, <%s>;rel="next"`, Link, url.String())
×
NEW
49

×
NEW
50
        }
×
51
        c.Header("Link", Link)
27✔
52
}
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