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

pace / bricks / 12058212013

27 Nov 2024 08:45PM UTC coverage: 57.508% (+0.04%) from 57.466%
12058212013

Pull #387

github

monstermunchkin
pkg/context: Add deprecation notice
Pull Request #387: tracing: Fix bugs and clean up code

19 of 29 new or added lines in 7 files covered. (65.52%)

2 existing lines in 1 file now uncovered.

5519 of 9597 relevant lines covered (57.51%)

21.8 hits per line

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

0.0
/tools/testserver/simple/open-api.go
1
// Code generated by github.com/pace/bricks DO NOT EDIT.
2
package simple
3

4
import (
5
        "context"
6
        errors1 "errors"
7
        sentry "github.com/getsentry/sentry-go"
8
        mux "github.com/gorilla/mux"
9
        errors "github.com/pace/bricks/maintenance/errors"
10
        metrics "github.com/pace/bricks/maintenance/metric/jsonapi"
11
        "net/http"
12
)
13

14
/*
15
GetTestHandler handles request/response marshaling and validation for
16

17
        Get /beta/test
18
*/
19
func GetTestHandler(service GetTestHandlerService) http.Handler {
×
20
        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
×
21
                defer errors.HandleRequest("GetTestHandler", w, r)
×
22

×
23
                // Trace the service function handler execution
×
24
                span := sentry.StartSpan(r.Context(), "http.server", sentry.WithDescription("GetTestHandler"))
×
25
                defer span.Finish()
×
26

×
27
                ctx := span.Context()
×
28
                r = r.WithContext(ctx)
×
29

×
30
                // Setup context, response writer and request type
×
31
                writer := getTestResponseWriter{
×
32
                        ResponseWriter: metrics.NewMetric("simple", "/beta/test", w, r),
×
33
                }
×
34
                request := GetTestRequest{
×
NEW
35
                        Request: r,
×
36
                }
×
37

×
38
                // Scan and validate incoming request parameters
×
39

×
40
                // Invoke service that implements the business logic
×
41
                err := service.GetTest(ctx, &writer, &request)
×
42
                select {
×
43
                case <-ctx.Done():
×
44
                        if ctx.Err() != nil {
×
45
                                // Context cancellation should not be reported if it's the request context
×
46
                                w.WriteHeader(499)
×
47
                                if err != nil && !(errors1.Is(err, context.Canceled) || errors1.Is(err, context.DeadlineExceeded)) {
×
48
                                        // Report unclean error handling (err != context err) to sentry
×
49
                                        errors.Handle(ctx, err)
×
50
                                }
×
51
                        }
52
                default:
×
53
                        if err != nil {
×
54
                                errors.HandleError(err, "GetTestHandler", w, r)
×
55
                        }
×
56
                }
57
        })
58
}
59

60
/*
61
GetTestResponseWriter is a standard http.ResponseWriter extended with methods
62
to generate the respective responses easily
63
*/
64
type GetTestResponseWriter interface {
65
        http.ResponseWriter
66
        OK()
67
}
68
type getTestResponseWriter struct {
69
        http.ResponseWriter
70
}
71

72
// OK responds with empty response (HTTP code 200)
73
func (w *getTestResponseWriter) OK() {
×
74
        w.Header().Set("Content-Type", "application/vnd.api+json")
×
75
        w.WriteHeader(200)
×
76
}
×
77

78
/*
79
GetTestRequest is a standard http.Request extended with the
80
un-marshaled content object
81
*/
82
type GetTestRequest struct {
83
        Request *http.Request `valid:"-"`
84
}
85

86
// Service interface for GetTestHandler handler
87
type GetTestHandlerService interface {
88
        // GetTest Test
89
        GetTest(context.Context, GetTestResponseWriter, *GetTestRequest) error
90
}
91

92
// Legacy Interface.
93
// Use this if you want to fully implement a service.
94
type Service interface {
95
        GetTestHandlerService
96
}
97

98
// GetTestHandlerWithFallbackHelper helper that checks if the given service fulfills the interface. Returns fallback handler if not, otherwise returns matching handler.
99
func GetTestHandlerWithFallbackHelper(service interface{}, fallback http.Handler) http.Handler {
×
100
        if service, ok := service.(GetTestHandlerService); ok {
×
101
                return GetTestHandler(service)
×
102
        } else {
×
103
                return fallback
×
104
        }
×
105
}
106

107
/*
108
Router implements: PACE Payment API
109

110
Welcome to the PACE Payment API documentation.
111
This API is responsible for managing payment methods for users as well as authorizing payments on behalf of PACE services.
112
*/
113
func Router(service interface{}) *mux.Router {
×
114
        router := mux.NewRouter()
×
115
        // Subrouter s1 - Path: /pay
×
116
        s1 := router.PathPrefix("/pay").Subrouter()
×
117
        s1.Methods("GET").Path("/beta/test").Name("GetTest").Handler(GetTestHandlerWithFallbackHelper(service, router.NotFoundHandler))
×
118
        return router
×
119
}
×
120

121
/*
122
Router implements: PACE Payment API
123

124
Welcome to the PACE Payment API documentation.
125
This API is responsible for managing payment methods for users as well as authorizing payments on behalf of PACE services.
126
*/
127
func RouterWithFallback(service interface{}, fallback http.Handler) *mux.Router {
×
128
        router := mux.NewRouter()
×
129
        // Subrouter s1 - Path: /pay
×
130
        s1 := router.PathPrefix("/pay").Subrouter()
×
131
        s1.Methods("GET").Path("/beta/test").Name("GetTest").Handler(GetTestHandlerWithFallbackHelper(service, fallback))
×
132
        return router
×
133
}
×
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