You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently API routers are responsible for transforming requests based upon API version, however this has lead to host specific details leaking into the http router.
We also don't really want API version specific details leaking into the implementation.
I propose that we add a shim here so that transformations can be made after the request is routed.
This could look something like:
// the API routerfunc(r*fooRouter) createFoo(ctx context.Context, w http.Response, req*http.Request) {
// make a fooConfig from the reuqestr.backend.Create(ctx, fooConfig)
}
func(t*fooTransformer) Create(ctx context.Context, fooConfig) {
ver:=getApiVersion(ctx)
ifver.LessThan("1.2") {
// set some value
}
}
Then the transformer can be configured with host specific details rather than relying on the HTTP router to have these details.
It also seems like it makes it easier to unit test such transformations.
The text was updated successfully, but these errors were encountered:
Where would that transform package live? Isn't API version (and what it supports) part of the API layer?
It is, but it doesn't need to be within the router.
I think we've mixed the HTTP interface (router) with the implementation of the API.
Some things need to be handled before the request is performed by the backend
Yes, that's pretty much the idea here.
Really I was not even considering output, which we also have some stuff mixed in with the engine implementation rather than in some API layer.
Currently API routers are responsible for transforming requests based upon API version, however this has lead to host specific details leaking into the http router.
We also don't really want API version specific details leaking into the implementation.
I propose that we add a shim here so that transformations can be made after the request is routed.
This could look something like:
Then the transformer can be configured with host specific details rather than relying on the HTTP router to have these details.
It also seems like it makes it easier to unit test such transformations.
The text was updated successfully, but these errors were encountered: