Max
Max

Reputation: 21

Rails impossible to get post response in rack middleware

I made a rails 3 rack middleware to log users actions with request = Rack::Request.new(env).

So i send to my database the request.fullpath and request.user_agent, as detailed below:

My issue appears I want to get the POST response too (to get ids, people name extracted from the JSON payload ...).

So i get the response = Rack::Response.new(request.path). But when i print response.body, i have only my request.path, and the request.params does not contain anything ...

By looking at the response with Firebug, I can see all the data I want.

Thanks for your responses.

Upvotes: 1

Views: 980

Answers (1)

Max
Max

Reputation: 21

Problem resolved !

I finally add status, headers, body = @app.call(env) to my middleware and send the body variable to my service. For each POST request, body contains all the post response I want.

Upvotes: 1

Related Questions