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

mendersoftware / deployments / 1197570064

01 Mar 2024 06:24PM UTC coverage: 52.222% (-28.4%) from 80.645%
1197570064

Pull #998

gitlab-ci

web-flow
chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore

Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.9.1...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #998: chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.9.1 to 1.10.0

5218 of 9992 relevant lines covered (52.22%)

0.55 hits per line

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

87.1
/utils/restutil/options.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 restutil
15

16
import (
17
        "net/http"
18

19
        "github.com/ant0ine/go-json-rest/rest"
20
)
21

22
const (
23
        HttpHeaderAllow string = "Allow"
24
)
25

26
type CreateOptionsHandler func(methods ...string) rest.HandlerFunc
27

28
type OptionsHandler struct {
29
        // Shared  reads, need locking of any write mathod is introduced.
30
        methods map[string]bool
31
}
32

33
// NewOptionsHandler creates http handler object that will server OPTIONS method requests,
34
// Accepts a list of http methods.
35
// Adds information that it serves OPTIONS method automatically.
36
func NewOptionsHandler(methods ...string) rest.HandlerFunc {
1✔
37
        handler := &OptionsHandler{
1✔
38
                methods: make(map[string]bool, len(methods)+1),
1✔
39
        }
1✔
40

1✔
41
        for _, method := range methods {
2✔
42
                handler.methods[method] = true
1✔
43
        }
1✔
44

45
        if _, ok := handler.methods[http.MethodOptions]; !ok {
2✔
46
                handler.methods[http.MethodOptions] = true
1✔
47
        }
1✔
48

49
        return handler.handle
1✔
50
}
51

52
// Handle is a method for handling OPTIONS method requests.
53
// This method is called concurrently while serving requests and should not modify self.
54
func (o *OptionsHandler) handle(w rest.ResponseWriter, r *rest.Request) {
×
55
        for method := range o.methods {
×
56
                w.Header().Add(HttpHeaderAllow, method)
×
57
        }
×
58
}
59

60
// AutogenOptionsRoutes automatically add OPTIONS method support for each defined route.
61
func AutogenOptionsRoutes(createHandler CreateOptionsHandler, routes ...*rest.Route) []*rest.Route {
1✔
62

1✔
63
        methodGroups := make(map[string][]string, len(routes))
1✔
64

1✔
65
        for _, route := range routes {
2✔
66
                methods, ok := methodGroups[route.PathExp]
1✔
67
                if !ok {
2✔
68
                        methods = make([]string, 0)
1✔
69
                }
1✔
70

71
                methodGroups[route.PathExp] = append(methods, route.HttpMethod)
1✔
72
        }
73

74
        options := make([]*rest.Route, 0, len(methodGroups))
1✔
75
        for route, methods := range methodGroups {
2✔
76
                options = append(options, rest.Options(route, createHandler(methods...)))
1✔
77
        }
1✔
78

79
        return append(routes, options...)
1✔
80
}
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