Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions kwikapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RamanjaneyuluIdavalapati What is this protocol used for??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaswanth098 We use that protocol to serialise the response/result.
By default JSON protocol will be used to serialise and deserialise the incoming(client sends data to the server) and outgoing(server sends data to the client) data.

We can change this default protocol. Ref

But this protocol will be used to serialise and deserialise for both incoming and outgoing data.
I have supported here such that the user can change the protocol for outgoing data.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it thanks for clarification


self._invoke_post_call_hook(request, result=result)

except TypeError as e:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '0.5.5'
version = '0.5.6'
setup(
name="kwikapi",
version=version,
Expand Down