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

path type path params can have default or be optional #219

Closed
derekdai opened this issue Dec 10, 2023 · 3 comments
Closed

path type path params can have default or be optional #219

derekdai opened this issue Dec 10, 2023 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@derekdai
Copy link
Contributor

derekdai commented Dec 10, 2023

According to document

path: like string but includes / chars. Doesn't provides optional and default.

But in fact, HappyX can handle it without problem (checked with -d:spaDebug), with one exception $p:path=/, this generates incorrect regex (re2("^/photo-rename([\\S]+)=/$")), but {p:path=/} work as expect.

Currently, if there is a problem with the processing of path parameters, you can only use -d:spaDebug or -d:ssrDebug to view the generated code to confirm that it matches your expectations. Would it be appropriate to change this to a compile-time error?

@derekdai derekdai added the documentation Improvements or additions to documentation label Dec 10, 2023
@Ethosa
Copy link
Contributor

Ethosa commented Dec 10, 2023

yea, I updated path some time ago - #217
I'll update docs soon

Ethosa added a commit that referenced this issue Dec 10, 2023
@Ethosa Ethosa closed this as completed Dec 10, 2023
@derekdai
Copy link
Contributor Author

derekdai commented Dec 11, 2023

@Ethosa I think this is worth mentioning in the documentation. When specifying a default value for a path path parameter, the value may contain a / character, so you must use the {arg} syntax instead of $arg, according to this line. Or simply remove the "Usage alias" for path (and regex?) from "examples/website/src/docs/path_params.nim".

Ethosa added a commit that referenced this issue Dec 11, 2023
Ethosa added a commit that referenced this issue Dec 11, 2023
Ethosa added a commit that referenced this issue Dec 11, 2023
@Ethosa
Copy link
Contributor

Ethosa commented Dec 11, 2023

@derekdai

I add error throwing when developer tries to use alias for regex or path. Also I update docs
image

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

No branches or pull requests

2 participants