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

Separation of jester routes between different modules or files. #51

Closed
ray-delossantos opened this issue Dec 8, 2015 · 4 comments
Closed
Labels

Comments

@ray-delossantos
Copy link

Hello:

I would like to divide a rest api project with jester into different src files:

Ex:
main.nim

    import jester, asyncdispatch
    import another_part
    routes:
      get "/":
        resp """ {"status": "ok"} """, "application/json"

another_part.nim

    import jester, asyncdispatch
    routes:
      get "/anotherpart":
        resp """ {"status": "ok"} """, "application/json"

The current behaviour is that on running like this it will try to open two web servers with the same port.

@dom96
Copy link
Owner

dom96 commented Dec 8, 2015

Thanks!

@dom96 dom96 added the Feature label Dec 8, 2015
@0x1eef
Copy link

0x1eef commented Dec 10, 2015

sinatra can be used to define a subclass that acts as a container for all routes defined inside it. the subclass can then be mounted to a namespace, like "/foobar" and then all paths defined within it become relative to /foobar. can jester do anything like that? if i understood this issue correctly, I guess not....

@PMunch
Copy link
Contributor

PMunch commented Oct 27, 2017

This should be really easy to implement if we take most of the body out of the route macro and put it in a matcher macro without this line: https://github.com/dom96/jester/blob/master/jester.nim#L842 (and maybe a better way to name the matcher). Then the route macro can wrap that macro to get the matcher and add the serve call. This way you would be able to create multiple matchers which can then be baked into one manual matcher as seen in example 2.

dom96 added a commit that referenced this issue Jun 14, 2018
dom96 added a commit that referenced this issue Jun 15, 2018
@dom96
Copy link
Owner

dom96 commented Jul 12, 2018

Implemented. See alltest for details.

@dom96 dom96 closed this as completed Jul 12, 2018
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

4 participants