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

mendersoftware / mender-server / 1902703503

02 Jul 2025 02:55PM UTC coverage: 65.459%. First build
1902703503

Pull #784

gitlab-ci

bahaa-ghazal
chore: Remove github.com/ant0ine/go-json-rest package from the backend

Ticket: MEN-8233
Signed-off-by: Bahaa Aldeen Ghazal <bahaa.ghazal@northern.tech>
Pull Request #784: refactor: Remove github.com/ant0ine/go-json-rest from the backend

52 of 72 new or added lines in 13 files covered. (72.22%)

31902 of 48736 relevant lines covered (65.46%)

1.39 hits per line

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

52.94
/backend/pkg/requestid/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
package requestid
15

16
import (
17
        "context"
18
        "net/http"
19
)
20

21
type requestIdKeyType int
22

23
const (
24
        requestIdKey requestIdKeyType = 0
25
)
26

27
// GetReqId helper for retrieving current request Id
28
func GetReqId(r *http.Request) string {
×
29
        return FromContext(r.Context())
×
30
}
×
31

32
// SetReqId is a helper for setting request ID in request context
NEW
33
func SetReqId(r *http.Request, reqid string) *http.Request {
×
34
        ctx := WithContext(r.Context(), reqid)
×
NEW
35
        r = r.WithContext(ctx)
×
36
        return r
×
37
}
×
38

39
// FromContext extracts current request Id from context.Context
40
func FromContext(ctx context.Context) string {
9✔
41
        val := ctx.Value(requestIdKey)
9✔
42
        if v, ok := val.(string); ok {
17✔
43
                return v
8✔
44
        }
8✔
45
        return ""
2✔
46
}
47

48
// WithContext adds request to context `ctx` and returns the resulting context.
49
func WithContext(ctx context.Context, reqid string) context.Context {
9✔
50
        return context.WithValue(ctx, requestIdKey, reqid)
9✔
51
}
9✔
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