carllerche / tower-web

A fast, boilerplate free, web framework for Rust
MIT License
980 stars 51 forks source link

Attribute 'get' is unknown #220

Closed Luminoth closed 5 years ago

Luminoth commented 5 years ago

I'm not sure what exactly I'm doing wrong, but my simple attempt at using tower_web is failing with this compile error:

The attribute `get` is currently unknown to the compiler and may have meaning added to it in the future

This is the resource section of my example:

#[derive(Clone, Debug)]
struct IndexResource;

#[derive(Response)]
struct IndexResponse {
    message: String,
}

impl_web! {
    impl IndexResource {
        #[get("/")]
        #[content_type("json")]
        fn index(&self) -> Result<IndexResponse, ()> {
            Ok(IndexResponse {
                message: "Hello World!".to_owned(),
            })
        }
    }
}

It seems like it should be working fine and I do have #[macro_use] extern crate tower_web; in my main.rs. Is there something else that I need to be doing to get this working?