1

I am writing a "partial proxy" in Mojolicious::Lite. Certain requests (depending on the query path, and on the values of the parameters) generate a request to another server, while others are handled locally.

There is a nice proxy example, but it totally overrides the request/response handling and thus is not suitable to my needs.

Currently, I am marshalling the response via

$self->render(data => $res->body, code => $res->code);

Unfortunately, this does not take into account different content types. Using Mojolicious::Type does not help, because I need a reverse mapping from the content type in $res to the format in render(); besides, the number of possible render formats is significantly smaller than the number of possible content types.

So ideally, instead of the $self->render() call above I need a way to say "here, I got a response in $res; please return it back to the client as is".

Any ideas? Thanks!

1 Answer 1

4

Ok, the trick was to replace render() call with

$self->tx->res($res);
$self->rendered($res->code);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.