http-rs / http-rs/tide

Missing easier way to return text/html content

Open
#534 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
5.1k
Forks
329
PR merge metrics
No merged PRs in 30d

Description

Looking at the 'graphql' example, I have to depend on the mime crate to set `text/html` content-type:

```
let res = Response::new(StatusCode::Ok)
.body_string(body)
.set_mime(mime::TEXT_HTML_UTF_8);
```

if I don't want to depend on the `mime` crate, I can do:

```
let res = Response::new(StatusCode::Ok)
.body_string(body)
.set_mime("text/html".parse().unwrap());
```

This looks non-optimal to me.

Such a basic use-case should be easier. I am wondering if I am missing an alternative.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.