mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Prettify indentation of code snippet examples in docs/README
This commit is contained in:
parent
2c621d2114
commit
5d6eee60d4
1 changed files with 30 additions and 33 deletions
|
@ -24,11 +24,10 @@ You can use this guide to work with SSL certificates.
|
||||||
# Use this example if you are using a pem file
|
# Use this example if you are using a pem file
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
include HTTParty
|
include HTTParty
|
||||||
|
|
||||||
base_uri "https://example.com"
|
|
||||||
pem File.read("#{File.expand_path('.')}/path/to/certs/cert.pem"), "123456"
|
|
||||||
|
|
||||||
|
base_uri "https://example.com"
|
||||||
|
pem File.read("#{File.expand_path('.')}/path/to/certs/cert.pem"), "123456"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -38,11 +37,10 @@ end
|
||||||
# Use this example if you are using a pkcs12 file
|
# Use this example if you are using a pkcs12 file
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
include HTTParty
|
include HTTParty
|
||||||
|
|
||||||
base_uri "https://example.com"
|
|
||||||
pkcs12 File.read("#{File.expand_path('.')}/path/to/certs/cert.p12"), "123456"
|
|
||||||
|
|
||||||
|
base_uri "https://example.com"
|
||||||
|
pkcs12 File.read("#{File.expand_path('.')}/path/to/certs/cert.p12"), "123456"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -52,11 +50,10 @@ end
|
||||||
# Use this example if you are using a pkcs12 file
|
# Use this example if you are using a pkcs12 file
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
include HTTParty
|
include HTTParty
|
||||||
|
|
||||||
base_uri "https://example.com"
|
|
||||||
ssl_ca_file "#{File.expand_path('.')}/path/to/certs/cert.pem"
|
|
||||||
|
|
||||||
|
base_uri "https://example.com"
|
||||||
|
ssl_ca_file "#{File.expand_path('.')}/path/to/certs/cert.pem"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -66,10 +63,10 @@ end
|
||||||
# Use this example if you are using a pkcs12 file
|
# Use this example if you are using a pkcs12 file
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
include HTTParty
|
include HTTParty
|
||||||
|
|
||||||
base_uri "https://example.com"
|
base_uri "https://example.com"
|
||||||
ssl_ca_path '/path/to/certs'
|
ssl_ca_path '/path/to/certs'
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -77,13 +74,13 @@ You can also include this options with the call:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Client
|
class Client
|
||||||
include HTTParty
|
include HTTParty
|
||||||
|
|
||||||
base_uri "https://example.com"
|
base_uri "https://example.com"
|
||||||
|
|
||||||
def self.fetch
|
def self.fetch
|
||||||
get("/resources", pem: (File.read("#{File.expand_path('.')}/path/to/certs/cert.pem"), "123456")
|
get("/resources", pem: (File.read("#{File.expand_path('.')}/path/to/certs/cert.pem"), "123456")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -92,18 +89,18 @@ end
|
||||||
In some cases you may want to skip SSL verification, because the entity that issue the certificate is not a valid one, but you still want to work with it. You can achieve this through:
|
In some cases you may want to skip SSL verification, because the entity that issue the certificate is not a valid one, but you still want to work with it. You can achieve this through:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
#Skips SSL certificate verification
|
# Skips SSL certificate verification
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
include HTTParty
|
include HTTParty
|
||||||
|
|
||||||
base_uri "https://example.com"
|
base_uri "https://example.com"
|
||||||
pem File.read("#{File.expand_path('.')}/path/to/certs/cert.pem"), "123456"
|
pem File.read("#{File.expand_path('.')}/path/to/certs/cert.pem"), "123456"
|
||||||
|
|
||||||
def self.fetch
|
def self.fetch
|
||||||
get("/resources", verify: false)
|
get("/resources", verify: false)
|
||||||
# You can also use something like:
|
# You can also use something like:
|
||||||
# get("resources", verify_peer: false)
|
# get("resources", verify_peer: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
Loading…
Add table
Reference in a new issue