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

Documentation: Basics #242

Open
komus-Israel opened this issue Jan 7, 2025 · 3 comments
Open

Documentation: Basics #242

komus-Israel opened this issue Jan 7, 2025 · 3 comments

Comments

@komus-Israel
Copy link

Localhost not completely stated alongside port
In the doc: println!("Server running at http://12");

params
In the Doc we have:

#[derive(Params)]
struct HelloParams {
    name: String,
}

#[handler]
fn hello(params: HelloParams) -> JsonResult {
    Ok(json!({
        "message": format!("Hello, {}!", params.name)
    }))
}

However, do you mean The Param derive macro which is used to derive a struct that can be used to parse route parameters instead ? As the above throws an error related to rustc --explain E0277

So we can have:

#[derive(Param)]
struct HelloParams {
    name: String,
}

#[handler]
fn hello(params: HelloParams) -> JsonResult {
    Ok(json!({
        "message": format!("Hello, {}!", params.name)
    }))
}
@elcharitas
Copy link
Member

Thanks for opening this issue @komus-Israel.

Quick one did you include the prelude?

use ngyn::prelude::*;

@komus-Israel
Copy link
Author

Yes. Added the prelude

@elcharitas
Copy link
Member

If you added the prelude, the only other possible thing would be you dont have serde and serde_json in your application.

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

No branches or pull requests

2 participants