Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
shrapnel
Commits
b9447f2d
Commit
b9447f2d
authored
Jun 15, 2013
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple json_rpc handler
parent
016d89ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
coro/http/json_rpc.py
coro/http/json_rpc.py
+24
-0
No files found.
coro/http/json_rpc.py
0 → 100644
View file @
b9447f2d
# -*- Mode: Python -*-
import
json
class
json_rpc_handler
:
def
__init__
(
self
,
root
):
self
.
root
=
root
def
match
(
self
,
request
):
return
request
.
method
==
'post'
and
request
.
path
==
'/jsonrpc'
def
handle_request
(
self
,
request
):
data
=
request
.
file
.
read
()
qd
=
json
.
loads
(
data
)
v2
=
qd
.
has_key
(
'jsonrpc'
)
result
=
self
.
root
.
handle_json_rpc
(
qd
[
'method'
],
qd
[
'params'
])
request
[
'content-type'
]
=
'application/json'
if
v2
:
rd
=
{
'jsonrpc'
:
'2.0'
,
'result'
:
result
,
'id'
:
qd
[
'id'
]}
else
:
rd
=
{
'result'
:
result
,
'error'
:
None
,
'id'
:
qd
[
'id'
]}
request
.
push
(
json
.
dumps
(
rd
))
request
.
done
()
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