Comments (2)
I agree. Or another strategy, such as setting default_body_params
For example, ping.fm's REST service (http://groups.google.com/group/pingfm-developers/web/api-documentation?_done=%2Fgroup%2Fpingfm-developers%3F) requires API and "user" keys on all requests, and they must be posted. Big drag to have to keep adding those params.
from httparty.
Here's a monkey patch . . .
module HTTParty
module ClassMethods
def default_body_params(h={})
raise ArgumentError, 'Default body params must be a hash' unless h.is_a?(Hash)
default_options[:default_body_params] ||= {}
default_options[:default_body_params].merge!(h)
end
end
class Request
def body
if options[:default_body_params]
if options[:body]
if options[:body].is_a?(Hash)
options[:body] = options[:default_body_params].merge(options[:body])
end
else
options[:body] = options[:default_body_params]
end
end
if options[:body].is_a?(Hash)
options[:body].to_params
else
options[:body]
end
end
end
end
from httparty.
Related Issues (20)
- 1:50: FATAL: Space required after the Public Identifier (Nokogiri::XML::SyntaxError) in ruby 3.0.3 HOT 1
- How to pass raw-data into post request using HTTParty HOT 2
- Feature - default headers HOT 1
- [BUG] HTTParty logger overrides Rails logger. HOT 2
- Configured timeout is duplicated HOT 4
- Question: Formatting an array of objects for multipart form-data
- Add application/problem+json to the supported formats HOT 1
- HTTParty response cache is broken HOT 1
- Is there a place to report security issues? HOT 1
- HTTParty.post is unusable HOT 12
- Bug in post function HOT 1
- HTTParty response body returning compressed GZipped data HOT 1
- Segmentation fault in request HOT 1
- Bundling Httparty results in ArgumentError: bad argument (expected URI object or URI string) HOT 1
- OpenSSL::SSL::SSLError HOT 2
- Is GHSA-5pq7-52mg-hr42 remotely exploitable?
- Adding Response Code Helper Methods like _401? HOT 2
- Add party foul mode HOT 1
- socks proxy only for special https links
- Preventing large payloads? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httparty.