Closed andrewemeryanz closed 4 years ago
I think it is a way to make progress on this problem, but it defeats the design principles of sysl-go. In particular:
only allowing source code dependencies to point "inward"
Following that principle, it should be noted that this is an interim solution and brings risks with it, i.e. testability and portability of the business logic. And should be remediated before wider adoption. For example:
restlib
.I can think of two options that uphold the principle but would require (possibly considerably) more work:
@gkanz Thanks. I agree that a custom abstraction would be better:
// definition: core package
type RestResult struct {
StatusCode int
Headers map[string][]string
Body []byte
}
// usage
response, err := client.GetRestFooBar(ctx, &request,
restlib.RestRequestOnResult(func(result *core.RestResult, err error) {
// access to http result and error
}))
However changing anything behaviourally (return value or errors) would require an additional client method to maintain backwards compatibility. I'm not sure I want to pull the trigger on that without a bigger rethink into what the end state looks like.
Replaced by https://github.com/anz-bank/sysl-go/pull/165.
In some instances, custom handler implementations require access to more information than downstream service calls currently permit.
Downstream service calls currently provide access to deserialised response body on successful requests, however in some instances the status code and headers are also required to be known.
Likewise, downstream services calls currently return an error for unsuccessful requests, however in some instances the status code, headers or response body are required to be known.
RestRequestOption instances can be passed into downstream REST requests to perform custom actions:
To support this, generated clients subsequently change:
Closes #105 #159