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

not yet implemented panic when parsing Json body #198

Closed
fuchsnj opened this issue Mar 16, 2019 · 4 comments
Closed

not yet implemented panic when parsing Json body #198

fuchsnj opened this issue Mar 16, 2019 · 4 comments

Comments

@fuchsnj
Copy link

fuchsnj commented Mar 16, 2019

Short error

thread 'tokio-runtime-worker-0' panicked at 'not yet implemented', /home/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-web-0.3.6/src/extract/serde.rs:71:17

Relevant bits of code

#[derive(Clone)]
pub struct ApiServer {
    challenge: Arc<Mutex<Challenge>>,
}

impl_web! {
    impl ApiServer {

        #[post("/secret")]
        fn check_secret_submission(&self, submission: SecretSubmission) -> Result<&'static str, ()> {
            println!("Submission: {:#?}", submission);
            Ok("done")
        }
    }
}

pub fn run(bind_addr: &'static str, challenge: Arc<Mutex<Challenge>>) {
    let addr = bind_addr.parse().expect("Invalid address");
    println!("API Server listening on http://{}", addr);

    // A service builder is used to configure our service.
    ServiceBuilder::new()
        .resource(ApiServer { challenge })
        .run(&addr)
        .unwrap();
}

#[derive(Extract, Debug, Serialize, Deserialize)]
pub struct SecretSubmission {
    secret: String
}

Dependency versions:

tower-web = "0.3.6"
tokio = "0.1.17"
serde = "1.0.89"

I can provide a full stacktrace if needed.

Questions:

  1. Am I doing this right? I couldn't find an example for JSON input
  2. Is there a workaround / way to make this work now?
  3. How can I help improve this? Even if I did something wrong it shouldn't panic.
@fuchsnj
Copy link
Author

fuchsnj commented Mar 16, 2019

@fuchsnj
Copy link
Author

fuchsnj commented Mar 16, 2019

ah, apparently the argument names are important. It's an easy fix, just change the argument name to body. Is a panic the expected behavior here?

@0xpr03
Copy link
Contributor

0xpr03 commented Mar 20, 2019

see also #183 (comment)

@fuchsnj
Copy link
Author

fuchsnj commented Mar 31, 2019

closing as a duplicate of #183

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