chridou / http-api-problem

A problem type to be returned by HTTP APIs
Apache License 2.0
53 stars 12 forks source link

lib: make to_hyper_response accept &self #26

Closed ernestas-poskus closed 3 years ago

ernestas-poskus commented 3 years ago

Make to_hyper_response method accept reference self. Similar function API exists on pub fn to_actix_response(&self) -> actix_web::HttpResponse that accept &self.

This allows to return hyper response without "move", in cases like this:

if let Some(error) = err.find::<problem::HttpApiProblem>() {
  return Ok(error.to_hyper_response());

cc @chridou

ernestas-poskus commented 3 years ago
Unrelated: `CI / build (--all-features, 1.39.0) (pull_request) `

error: cannot find macro `matches` in this scope
  --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-2.0.0/src/timeout.rs:61:38
   |
61 |             TimeoutError::Timeout => matches!(other, TimeoutError::Timeout),
   |                                      ^^^^^^^

error: aborting due to previous error

error: could not compile `actix-utils`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Process completed with exit code 101.