I am attempting to write a simple api with rocket to help myself learn rust but I have run into this error after I attempted declaring a POST route:
error: malformed attribute
--> src/main.rs:26:1
|
26 | #[post("/producers", format="application/json", data =<"prod">)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: expected syntax: #[post(key = value, ..)]
Here is the function declaration for that route:
#[post("/producers", format="application/json", data =<"producer">)]
fn post_producer(producer: Json<Producer>) -> String {
return("hello".to_string());
}
And I am importing these macros:
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate rocket_contrib;
use rocket_contrib::json::Json;
I have another method declared for GET but that one works fine. I've done some research and found these examples and documentation: https://api.rocket.rs/v0.4/rocket_codegen/attr.post.html https://rocket.rs/v0.4/guide/requests/#format
As far as I can tell I am following the conventions mentioned in both of those pages and I'm a bit lost on where to go from here. Is there some bit of syntax or an import that I'm missing?