Skip to content

Requests should have Content-Type: application/json #15

@quad

Description

@quad

The documentation strongly suggests that the content-type is set to JSON, but this doesn't happen anywhere!

We're using the following middleware … but it would be nice if it was included by default.

pub struct ContentTypeMiddleware;

impl MiddleWare for ContentTypeMiddleware {
    fn request<E>(
        &self,
        _: &E,
        req: &mut http::request::Request<Vec<u8>>,
    ) -> Result<(), ClientError>
    where
        E: Endpoint,
    {
        req.headers_mut()
            .append("content-type", HeaderValue::from_static("application/json"));

        Ok(())
    }

    fn response<E>(
        &self,
        _: &E,
        _: &mut http::response::Response<Vec<u8>>,
    ) -> Result<(), ClientError>
    where
        E: Endpoint,
    {
        Ok(())
    }
}

Would you be open to a PR adding this default behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions