rustless / rustless

REST-like API micro-framework for Rust. Works with Iron.
MIT License
618 stars 50 forks source link

Access iron request object #77

Open flosse opened 7 years ago

flosse commented 7 years ago

How can I get access to the iron request?

For example with the persistent crate, I'd do s.th. like this:

let mutex = request.get::<Write<Store>>().unwrap();

but client.request is not the irons request object.

s-panferov commented 7 years ago

@flosse I'm not sure that we should expose Iron here because Rustless possibly can work with another backend.

flosse commented 7 years ago

I'm not sure that we should expose Iron here because Rustless possibly can work with another backend.

I see. So accessing iron extensions is generally not possible?

s-panferov commented 7 years ago

@flosse I'll try to make something with it.

s-panferov commented 7 years ago

The main problem is that we use backend::Request as a Trait, but Pluggable methods are not object-safe.

So we have two ways to fix this:

  1. Expose Iron request as-is instead of our trait (with "iron" feature).
  2. Expose get_iron_request() -> iron::Request method.
flosse commented 7 years ago
  1. Expose Iron request as-is instead of our trait (with "iron" feature).

No, I think that will cause troubles :-\

Expose get_iron_request() -> iron::Request method.

That's better, because it's explicit but I'd call it just iron_request().