Skip to content

Commit 886daaa

Browse files
authored
Merge pull request #89 from RamanjaneyuluIdavalapati/master
Setting outgoing protocol
2 parents 7b2716c + 9963a2e commit 886daaa

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ deploy:
1616
- LICENSE
1717
- kwikapi/api.py
1818
- kwikapi/__init__.py
19-
name: kwikapi-0.5.5
20-
tag_name: 0.5.5
19+
name: kwikapi-0.5.6
20+
tag_name: 0.5.6
2121
on:
2222
repo: deep-compute/kwikapi
2323
- provider: pypi

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ True
356356
> We can also register same methods with same namespace with different versions
357357
358358
### Customizing request and response
359-
User can change the response if he wants it
359+
User can change the response attributes if he wants it
360360

361361
```python
362362
>>> import json
@@ -507,6 +507,16 @@ $ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: messagep
507507
$ wget "http://localhost:8888/api/v1/subtract" --header="X-KwikAPI-Protocol: json" --post-data '{"a": 10, "b": 20}'
508508
$ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: pickle" --post-file /tmp/data.pickle
509509
$ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: numpy" --post-file /tmp/data.numpy
510+
$ wget "http://localhost:8888/api/v1/add?a=10&b=20" --header="X-KwikAPI-Protocol: raw"
511+
```
512+
513+
#### We can also change outgoing protocol
514+
ex:
515+
```python
516+
class Calc(object):
517+
def add(self, req: Request, a: int, b: int) -> int:
518+
req.headers['X-KwikAPI-Protocol'] = 'numpy'
519+
return a + b
510520
```
511521

512522
### API Doc

kwikapi/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ def handle_request(self, request):
520520
self._invoke_pre_call_hook(request)
521521
result = request.fn(**request.fn_params)
522522

523+
protocol = self._find_request_protocol(request)
524+
523525
self._invoke_post_call_hook(request, result=result)
524526

525527
except TypeError as e:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
version = '0.5.5'
3+
version = '0.5.6'
44
setup(
55
name="kwikapi",
66
version=version,

0 commit comments

Comments
 (0)