diff --git a/.travis.yml b/.travis.yml index ede25d4..1205b5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ deploy: - LICENSE - kwikapi/api.py - kwikapi/__init__.py - name: kwikapi-0.5.5 - tag_name: 0.5.5 + name: kwikapi-0.5.6 + tag_name: 0.5.6 on: repo: deep-compute/kwikapi - provider: pypi diff --git a/README.md b/README.md index d36f826..612cd5c 100644 --- a/README.md +++ b/README.md @@ -356,7 +356,7 @@ True > We can also register same methods with same namespace with different versions ### Customizing request and response -User can change the response if he wants it +User can change the response attributes if he wants it ```python >>> import json @@ -507,6 +507,16 @@ $ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: messagep $ wget "http://localhost:8888/api/v1/subtract" --header="X-KwikAPI-Protocol: json" --post-data '{"a": 10, "b": 20}' $ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: pickle" --post-file /tmp/data.pickle $ wget "http://localhost:8888/api/v1/add" --header="X-KwikAPI-Protocol: numpy" --post-file /tmp/data.numpy +$ wget "http://localhost:8888/api/v1/add?a=10&b=20" --header="X-KwikAPI-Protocol: raw" +``` + +#### We can also change outgoing protocol +ex: +```python +class Calc(object): + def add(self, req: Request, a: int, b: int) -> int: + req.headers['X-KwikAPI-Protocol'] = 'numpy' + return a + b ``` ### API Doc diff --git a/kwikapi/api.py b/kwikapi/api.py index de7e5c1..77ea100 100644 --- a/kwikapi/api.py +++ b/kwikapi/api.py @@ -520,6 +520,8 @@ def handle_request(self, request): self._invoke_pre_call_hook(request) result = request.fn(**request.fn_params) + protocol = self._find_request_protocol(request) + self._invoke_post_call_hook(request, result=result) except TypeError as e: diff --git a/setup.py b/setup.py index 4ab6421..f1f00d9 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.5.5' +version = '0.5.6' setup( name="kwikapi", version=version,