-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REST] Add basePath configuration #918
Comments
+1
I am not convinced the base path should become a configuration aspect of the REST server. When doing top-down approach, shouldn't we pick it from the Swagger/OpenAPI spec? Also as was discussed in our Slack, we need to take into consideration different places where one may want to specify basePath, for example in the spec passed to controller's |
If we're building a bottom-up spec then we need a way to specify what that value is in a bottom-up way. We might want to read that value from the spec instance, but we don't want to make it exclusively configurable in the top-down approach. |
I see, that makes sense. Isn't it enough to configure base path(s) on controller level, as we are already supporting now? Since each HTTP/Rest server is owning it's entire path namespace, if we configure the base path at rest server level, then every URL served by this particular server will have to start with that base path. I.e. if our app has a RestServer listening on |
@bajtos Is it possible for for the base paths to be used only on the routes that are registered through controllers? |
My understanding of a decorator for basePath would that it would only apply to the API's (and not static files / explorer) ... ideally explorer would have it's own config for the path in the future (or even having it enabled / disabled). Same goes for static files (it's own config). I would also like to see basePath be capable of building up a nested path. For example:
|
IMO, the
I think we can add decorators to @api(...)
class MyApplication extends Application {
} |
I agree with Raymond's comment that I am not sure if it's a good idea to allow the Another important thing to consider: OpenAPIv3 does not have any Also in my view, design-first approach is mutually exclusive with I think we should allow What's more important, our current design is not forcing people to subclass application/server class, it's possible to build an app using vanilla const app = new RestApplication();
app.controller(MyController);
app.start(); Based on the above, I am proposing to NOT allow // direct usage
const app = new RestApplication();
app.basePath = '/api';
app.controller(MyController);
app.start();
// usage in an app subclass
class MyApp extends RestApplication {
constructor() {
this.basePath = '/api';
}
} Thoughts? |
+1 for having a top-level property for configuring the |
+1 to expose To provide base path for a controller class, I see two options:
@path('/customers')
export class CustomerController {
}
|
I like option 1 -- |
Right now,
+1 for this option. I personally prefer a different name - class MyApp extends RestApplication {
constructor() {
this.path = '/api';
}
} |
For clarification, if a user was to set the base path as |
I image the following is how
|
+1 for what TV wrote above. |
I think we should move
|
Removed from 4.0 GA, moved to [EPIC] REST layer improvements (post-GA) #1452 |
Implemented by #2097 |
linked to #914
Overview
Currently, we do not have proper
basePath
support in the RestServer for the supported bottom-up approach. Let's address that by allowing users to pass these values in via options OR inject via the appropriate key.Acceptance Criteria
BASE_PATH
binding toRestBindings
RestServer
moduleBASE_PATH
binding under the hood/
if not specifiedBASE_PATH
to be registered through abasePath()
functionRestBindings.BASE_PATH
for all routesBASE_PATH
binding)The text was updated successfully, but these errors were encountered: