-
Notifications
You must be signed in to change notification settings - Fork 30
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
More flexible methods for Endpoint and Routing #32
Conversation
RobinTail
commented
Jun 5, 2021
•
edited
Loading
edited
- A more convenient way to specify a single method to the Endpoint.
- Ability to assign multiple Endpoints to a single Route depending on Method (the issue: Question: Different I/O for different methods #29)
- Ability for the Endpoint to handle multiple methods of the single Route at the same time
…st the corresponding one.
export type MethodsDefinition<M extends Method> = { | ||
methods: M[]; | ||
} | { | ||
method: M; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two ways to specify the Endpoint method(s).
export const v1Routing: Routing = { | ||
// syntax 1: methods are defined within the endpoint | ||
getUser: getUserEndpoint, | ||
setUser: setUserEndpoint | ||
|
||
// syntax 2: methods are defined within the route | ||
setUser: new DependsOnMethod({ | ||
post: setUserEndpoint // the Endpoint should have at least the same method specified in .build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A route can have multiple handlers (with different I/O schemas) depending on different methods.
It can also be the same Endpoint that handle different methods as well.