Closed scauglog closed 3 years ago
I can get it if i use request.env["api.endpoint"].params.to_h
or env["api.endpoint"].params.to_h
instead of request.params
I don't know if there is any edge case, so i have created a new "loggers" named url_params. Tell me if you prefer modify request_logger.rb instead.
Hi, Same here, I tried your changes which seem to work fine.
@scauglog do you declare you params also in params
block like below or only in the url string?
params do
requires :id, type: Integer
end
get 'sth/:id' do
end
yes, I also declare my params in the params block
Same problem here.
Previously I was using https://github.com/ridiculous/grape-middleware-logger which leverages the official Grape::Middleware::Globals to retrieve parameters.
This is how it reads the values pre-set by this other middleware
One solution would be to rely on Grape::Request.new
(which has an enhanced params) as you can see here instead of Rack.request which is what this library currently uses.
Another solution is just to implement the parameters retrieval like in ridiculous/grape-middleware-logger
although it will add the dependency on the global middleware.
What do you think?
c
when there is url parameters like
there is no key "some_url" in the params hash.