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

[RFC] Revisit jester architecture: expose router class #99

Closed
yglukhov opened this issue Jan 27, 2017 · 4 comments
Closed

[RFC] Revisit jester architecture: expose router class #99

yglukhov opened this issue Jan 27, 2017 · 4 comments
Labels

Comments

@yglukhov
Copy link
Contributor

There are already some feature requests that I can't see a good fit in the current architecture as currently jester more looks to me like a demo of fancy nim capabilities rather than full blown (micro) framework, even though we're using it in production =). The following architecture suggestion will make jester much more flexible, extensible and reusable IMO:

Do a Router class which is essentially a mapper_and_dispatcher of Requests to Handlers with smth like the following interface:

proc add*(router: Router, method: HttpMethod | string, urlPattern: string, callback: proc(r: Request): Future[void]) # adds handler to the pool. Lowest-level variant
proc remove*(router: Router, method: HttpMethod | string, urlPattern: string) # Removes the handler
proc dispatch*(router: Router, request: Request) {.async.}

The other higher-level bits of API should now be trivial to implement on top of that.
Overall this would allow using the router (which is IMO the key part of jester) in a custom server, split handlers across files and routers, use several routers per single server, create authentication/session handlers and similar request preprocessors/postprocessors, etc.

Does it make sense?

@yglukhov yglukhov changed the title Revisit jester architecture: expose router class [RFC] Revisit jester architecture: expose router class Jan 27, 2017
@dom96
Copy link
Owner

dom96 commented Jan 27, 2017

Makes sense. Hopefully soon I can stop neglecting Jester :)

@dom96
Copy link
Owner

dom96 commented Jul 12, 2018

There is now the ability to register multiple matchers. Matchers are called on all requests and are expected to perform their own routing.

@dom96 dom96 added the Feature label Jul 12, 2018
@yglukhov
Copy link
Contributor Author

Cool!

@dom96
Copy link
Owner

dom96 commented Jul 13, 2018

I think this will work as "middleware support" too. I'll add remove and dispatch too once I need them, if you still need them let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants