Skip to content

Commit de92991

Browse files
committed
refactor: pass actual context to getDataAccessor
1 parent 6dbf323 commit de92991

File tree

2 files changed

+124
-101
lines changed

2 files changed

+124
-101
lines changed

backend/pkg/api/handlers/handler_service.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ func NewHandlerService(dataAccessor dataaccess.DataAccessor, dummy dataaccess.Da
4949
// getDataAccessor returns the correct data accessor based on the request context.
5050
// if the request is mocked, the data access dummy is returned; otherwise the data access service.
5151
// should only be used if getting mocked data for the endpoint is appropriate
52-
func (h *HandlerService) getDataAccessor(r *http.Request) dataaccess.DataAccessor {
53-
if isMocked(r) {
52+
func (h *HandlerService) getDataAccessor(ctx context.Context) dataaccess.DataAccessor {
53+
if isMocked, ok := ctx.Value(types.CtxIsMockedKey).(bool); ok && isMocked {
5454
return h.daDummy
5555
}
5656
return h.daService
@@ -618,8 +618,3 @@ func (intOrString) JSONSchema() *jsonschema.Schema {
618618
},
619619
}
620620
}
621-
622-
func isMocked(r *http.Request) bool {
623-
isMocked, ok := r.Context().Value(types.CtxIsMockedKey).(bool)
624-
return ok && isMocked
625-
}

0 commit comments

Comments
 (0)