Skip to content
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

How to return arbitrary result? #133

Open
TvoroG opened this issue Oct 3, 2019 · 7 comments
Open

How to return arbitrary result? #133

TvoroG opened this issue Oct 3, 2019 · 7 comments

Comments

@TvoroG
Copy link

TvoroG commented Oct 3, 2019

Thanks a lot for the module!

I want to wrap json object into callback:

callback({"foo": "bar"})

I don't know how to do that. I've tried to return result as simple string from tarantool with following nginx config:

tnt_pass router;
tnt_method 'foo_method';
tnt_pure_result on;
tnt_multireturn_skip_count 2;

But module returns it wrapped into double quotes

"callback({\"foo\": \"bar\"})"
@snoopcatt
Copy link
Contributor

Please, show your foo_method code.

@TvoroG
Copy link
Author

TvoroG commented Oct 21, 2019

It simply returns a string

function foo_method()
    return 'callback({"foo": "bar"})'
end

@snoopcatt
Copy link
Contributor

And what do you expect?

@Totktonada
Copy link
Member

@TvoroG
Copy link
Author

TvoroG commented Oct 21, 2019

I'm expecting callback({\"foo\": \"bar\"}) but it returns "callback({\"foo\": \"bar\"})".

Try something like this: https://github.com/tarantool/nginx_upstream_module/tree/82355b8a1276ad584308f3ee4cc6e6129ecb302f#http-headers-and-status

Thanks, but i was hoping to do it without lua on nginx.

@TvoroG TvoroG closed this as completed Oct 21, 2019
@Totktonada
Copy link
Member

I agree that it is not convenient to add extra logic on nginx side just to implement an API you need. AFAIU the module was initially made with RPC in a mind, that is why we need to preprocess-postprocess a request and a response to implement, say, restful API. However it would be good to change it in the future.

@Totktonada
Copy link
Member

Hope we should not close the issue, but rather add an option that will do something like the Lua code that I linked above.

@Totktonada Totktonada reopened this Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants