#handler #hyper-server #web #error #service #api #request

luminal-handler

Slightly more convenient API on top of hyper::server::Service

5 releases

Uses old Rust 2015

0.0.5 Mar 25, 2018
0.0.4 Mar 25, 2018
0.0.3 Mar 25, 2018
0.0.2 Mar 24, 2018
0.0.1 Mar 12, 2018

#23 in #hyper-server


Used in luminal-router

Apache-2.0

8KB
142 lines

luminal-handler

A crate to provide a trait to implement and a function to call to lift non-future aware request handling into hyper.

Why

hyper::server::Service isn't a super forgiving API. It exposes the plumbing of futures pretty directly and makes error handling unclear. It is hoped that this create provides an easier API without sacrificing much, if any performance. In particular, the trait IntoResponse is introduced to help caller's use their own error kinds, layering in what is needed to convert those errors into valid hyper::server::Response instances.

TODO

  • Add handler_fn to match hyper's service_fn
  • Improve error handling
    • Support status code and response body for error
  • Add tests
  • Figure out how to pass additional information with requests cleanly
    • A preliminary enum now exists
    • Usage is likely to be driven by have luminal-pathparam and luminal-middleware evolve.
  • Add examples to docs
  • Add examples to example crate

Dependencies

~9MB
~151K SLoC