Skip to content
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

Merged
merged 19 commits into from
Jun 6, 2021
Merged

Conversation

RobinTail
Copy link
Owner

@RobinTail RobinTail commented Jun 5, 2021

  1. A more convenient way to specify a single method to the Endpoint.
  2. Ability to assign multiple Endpoints to a single Route depending on Method (the issue: Question: Different I/O for different methods #29)
  3. Ability for the Endpoint to handle multiple methods of the single Route at the same time

Comment on lines +5 to +9
export type MethodsDefinition<M extends Method> = {
methods: M[];
} | {
method: M;
};
Copy link
Owner Author

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).

@RobinTail RobinTail added enhancement New feature or request good first issue Good for newcomers labels Jun 5, 2021
@RobinTail RobinTail marked this pull request as ready for review June 5, 2021 22:21
@RobinTail RobinTail linked an issue Jun 5, 2021 that may be closed by this pull request
Comment on lines +5 to +11
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()
Copy link
Owner Author

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.

@RobinTail RobinTail merged commit 7490234 into master Jun 6, 2021
@RobinTail RobinTail deleted the methods-or-method branch June 6, 2021 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Different I/O for different methods
1 participant