New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about ctx.JSON #1153

Open
CuteLilTwo opened this Issue Dec 10, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@CuteLilTwo
Copy link

CuteLilTwo commented Dec 10, 2018

When I write the api,and interaction using JSON strings,I want to encrypt the request body,but in "ctx.JSON()",I can't find how to add the encrypt func to encrypt my request body.Could you please tell me how to do this.

@kataras

This comment has been minimized.

Copy link
Owner

kataras commented Dec 11, 2018

You are right, in fact, I am working on signing/verification and optional encryption/decryption for Iris' HTTP responses and requests, it will be there on the next version.

But you don't have to wait me, currently you can't do that from the ctx.JSON but you have access to your request body by: ioutil.ReadAll(ctx.Request().Body), take the data, encrypt them and then send them to the client using ctx.JSON or ctx.ContentType("..."); ctx.Write(b) -- ctx.JSON is not for request body, it is for response, plesae read the examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment