Webframework with magical procedural macro

I had been working on a new web-framework called jeep train.

Though it's completely experimental, I was trying to explore ways to minimize boilerplate, learning cost and if it is possible to write a router like you do in ruby or elixir.

Router looks like this.

router! {
    const NAME_OF_THE_ROUTER;
    scope "/api" {
        scope "/v1" {
            get api::v1::get;
            post api::v1::create;
            delete api::v1::destroy;
        }
    }
    scope "/resource" {
        resource index::resource;
    }
}

It's been half a year since I last updated, but finally got some time to continue with the development again!
I'd appreciate your feedback!

3 Likes

While this is very interesting, I don't know how practical it is. I think, having to define absolutely everything inside macros is a little bit over the top.

1 Like

I like the rocket.rs's aproach to this, it uses prosedural macros and they are very common in Rust. Using so much declarative macros and almost creating a new language is not a good way of designing libraries IMHO.

Your router macro don't seems compicated to me but as the number of macros increases, your library might become complicated for users. I recommend using prosedural macros macros if this is the case.

I'd like to remind people to keep unstructured critique to a minumum. Rather than just disliking how something is done, please give specific examples of its disadvantages or problems, or specific improvements and their trade-offs.

2 Likes

Well, at this point the framework only has 3 macros and syntax is pretty straight forward; at this point I don't find it necessary to introduce new macro so, I don't think that would be a problem.

And the great thing about the router macro is that you get to compile your router into a match statement. Which is very fast compare to runtime compiled stuff.

Also, router! macro is a procedural macro.

1 Like

Concerning the router, the macro compile the input into match statement, so even if you think it is over the top, you still get the sweet sweet buff on runtime performance.
It's extensible as well; you could, for example, pass a path to a swagger file which you could possibly compile a router from.

so I think it's great

I am doing similar thing in my framework, so i am all in for that.

If you like the way you have done it, then keep it up.

Thanks!

You got your self a nice project.
Good luck with the development!

1 Like

Thanks, you too.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.