shio-rs
shio-rs copied to clipboard
Procedural macro for routing
This is the first part for procedural macro for routing, very basic, only GET and POST.
This is currently nightly-only (relies on procedural macro attributes, not stable yet).
It's exposed into shio and shio::prelude under the nightly feature.
See the hello_macros examples for how to use it for get request.
Coverage remained the same at 79.762% when pulling 9119358b0b5743c68a13f1262a3c72a343c0996a on Meralis40:shio-macro into 033a0b599af8f1564b097e4019883c2aab59c4be on mehcode:master.
Coverage remained the same at 79.762% when pulling 4d433c11a644da53ba62edec2e5ab5457bf9de4d on Meralis40:shio-macro into 033a0b599af8f1564b097e4019883c2aab59c4be on mehcode:master.
#[allow(non_camel_case_types)]
struct __shio_route_hello {
}
impl Clone for __shio_route_hello {
fn clone(&self) -> Self { *self }
}
impl Copy for __shio_route_hello { }
#[allow(non_upper_case_globals)]
static hello: __shio_route_hello = __shio_route_hello{};
impl Into<::shio::router::Route> for __shio_route_hello {
fn into(self) -> ::shio::router::Route {
(::shio::Method::Get, "/{name}", __shio_handler_hello).into()
}
}
Neat solution to non-moveable statics with the newtype plus impl. I'd suggest shortening it up a bit with a ZST:
#[allow(non_camel_case_types)]
struct hello;
impl Into<::shio::router::Route> for hello {
fn into(self) -> ::shio::router::Route {
(::shio::Method::Get, "/{name}", __shio_handler_hello).into()
}
}
@Meralis40 Over all, nice work! Let's get this cleaned up a bit and we can merge it in.
I'd love to see the "standard" methods before this is released though:
getpostpatchputdeleteoptionshead
@mehcode All changes have been done, except complete clippy, because of "needless_pass_by_value" warning. Also, I've change the generated code as suggested & added the "standard" methods
Coverage remained the same at 79.762% when pulling cfd41a2a56f0d3eb877421ce76e1b143276326d6 on Meralis40:shio-macro into 033a0b599af8f1564b097e4019883c2aab59c4be on mehcode:master.
Rebased