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

const support in #[server] macro endpoint field #2938

Open
tetuaoro opened this issue Sep 6, 2024 · 2 comments
Open

const support in #[server] macro endpoint field #2938

tetuaoro opened this issue Sep 6, 2024 · 2 comments

Comments

@tetuaoro
Copy link

tetuaoro commented Sep 6, 2024

Is your feature request related to a problem? Please describe.
No.

I like to use const wherever I can in the code. So I tried to use a const in the macro #[server] but it's not supported.

Example :

const HELLO_ROUTE: &str = "...";

#[server(endpoint = "HELLO_ROUTE")]
pub async fn hello() -> Result<...> {...}

Of course, the constant is used twice in the code, just like in middleware. So why not implement #[server(fullpath = "...")]. This field overrides the prefix and endpoint fields.

EDIT: maybe, fullpath is another feature.

@gbj
Copy link
Collaborator

gbj commented Sep 6, 2024

PR welcome. @rakshith-ravi raised a similar idea recently I believe. It would require replacing the current form of constant string concatenation, which uses const_format::concatcp!() and only accepts literals, with some kind of const string slice concatenation like this pair.

@rakshith-ravi
Copy link
Collaborator

Yusss. I have a very basic wip with me. Haven't found too much time to work more on it. Happy to collaborate with you @tetuaoro if you're interested in working on this. I'm here on discord (you can find me on the Leptos discord as well)

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

No branches or pull requests

3 participants