Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weixin_authorize
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
weixin_authorize
Commits
46c2f71b
Commit
46c2f71b
authored
Feb 11, 2015
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more rest_client options config
parent
7c07e087
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
lib/weixin_authorize.rb
+6
-2
lib/weixin_authorize/config.rb
+9
-3
spec/spec_helper.rb
+1
-0
No files found.
lib/weixin_authorize.rb
View file @
46c2f71b
...
...
@@ -31,13 +31,17 @@ module WeixinAuthorize
def
http_get_without_token
(
url
,
headers
=
{},
endpoint
=
"plain"
)
get_api_url
=
endpoint_url
(
endpoint
,
url
)
load_json
(
RestClient
.
get
(
get_api_url
,
:params
=>
headers
))
load_json
(
resource
(
get_api_url
).
get
(
params:
headers
))
end
def
http_post_without_token
(
url
,
payload
=
{},
headers
=
{},
endpoint
=
"plain"
)
post_api_url
=
endpoint_url
(
endpoint
,
url
)
payload
=
JSON
.
dump
(
payload
)
if
endpoint
==
"plain"
# to json if invoke "plain"
load_json
(
RestClient
.
post
(
post_api_url
,
payload
,
:params
=>
headers
))
load_json
(
resource
(
post_api_url
).
post
(
payload
,
params:
headers
))
end
def
resource
(
url
)
RestClient
::
Resource
.
new
(
url
,
rest_client_options
)
end
# return hash
...
...
lib/weixin_authorize/config.rb
View file @
46c2f71b
...
...
@@ -9,12 +9,18 @@ module WeixinAuthorize
end
def
weixin_redis
return
nil
if
WeixinAuthorize
.
config
.
nil?
@redis
||=
WeixinAuthorize
.
config
.
redis
return
nil
if
config
.
nil?
@redis
||=
config
.
redis
end
# 可选配置: RestClient timeout, etc.
# key 必须是符号
def
rest_client_options
config
.
rest_client_options
||
{
timeout:
2
,
open_timeout:
3
,
verify_ssl:
true
}
end
end
class
Config
attr_accessor
:redis
attr_accessor
:redis
,
:rest_client_options
end
end
spec/spec_helper.rb
View file @
46c2f71b
...
...
@@ -55,6 +55,7 @@ redis_with_ns = Redis::Namespace.new("#{namespace}", :redis => redis)
WeixinAuthorize
.
configure
do
|
config
|
config
.
redis
=
redis_with_ns
config
.
rest_client_options
=
{
timeout:
1
,
open_timeout:
1
,
verify_ssl:
true
}
end
$client
=
WeixinAuthorize
::
Client
.
new
(
ENV
[
"APPID"
],
ENV
[
"APPSECRET"
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment