Skip to content

Conversation

@deptyped
Copy link
Contributor

@deptyped deptyped commented Jul 8, 2020

Now all you have to do to change the serialization or deserialization is pass the function to the dispatcher, like this:

import ujson from flask import Flask, request, Response from jsonrpcserver import method, dispatch app = Flask(__name__) @method def ping(): return "pong" @app.route("/", methods=["POST"]) def index(): response = dispatch(request.get_data().decode(), serialize=ujson.dumps, deserialize=ujson.loads) return Response(str(response), response.http_status, mimetype="application/json") if __name__ == "__main__": app.run()
Copy link
Member

@bcb bcb left a comment

Choose a reason for hiding this comment

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

LGTM

@bcb bcb merged commit 8f3437a into explodinglabs:master Jul 8, 2020
@bcb
Copy link
Member

bcb commented Jul 8, 2020

Thanks @deptyped 👌

@deptyped deptyped deleted the feature/custom-serializer-deserializer branch July 8, 2020 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants