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

feature: Support echo plugin #1225

Closed
agile6v opened this issue Mar 9, 2020 · 18 comments · Fixed by #1632 or #1708
Closed

feature: Support echo plugin #1225

agile6v opened this issue Mar 9, 2020 · 18 comments · Fixed by #1632 or #1708
Labels
enhancement New feature or request

Comments

@agile6v
Copy link
Member

agile6v commented Mar 9, 2020

APISIX currently provides a simple example plugin, but it does not provide useful functionality. So we can provide a useful plugin to help users understand as fully as possible how to develop an APISIX plugin.

@moonming moonming changed the title GSoC: Support echo plugin feature: Support echo plugin Mar 9, 2020
@moonming moonming added enhancement New feature or request GSoC labels Mar 9, 2020
@Akayeshmantha
Copy link
Member

Hi @agile6v @moonming will be applying for GSoC 2020 this year. Would like to give it a try with apache APISIX. I did GSoC 2019 with openMRS. Is there a chat room which talks about the project idea.

@moonming
Copy link
Member

moonming commented Mar 9, 2020

@Akayeshmantha Cool, you can add your ideas to https://cwiki.apache.org/confluence/display/COMDEV/GSoC+2020+Ideas+list, and we can talk about in slack: https://the-asf.slack.com/
, and serach the apisix channel.

@agile6v
Copy link
Member Author

agile6v commented Mar 9, 2020

This plugin could implement the corresponding functionality in the common phases such as init, rewrite, access, balancer, header filer, body filter and log . But the specific functionality are still being considered.

@Akayeshmantha
Copy link
Member

Hi @membphis @moonming @agile6v I hope still this is a valid requirement.

So here we are thinking about extending the already existing example plugin if am right?.

@agile6v
Copy link
Member Author

agile6v commented May 14, 2020

Hi @Akayeshmantha

As far as i am concerned, this plugin is still necessary to help other people understand how to implement a plugin as fully as possible.

Thanks.

@Akayeshmantha
Copy link
Member

@agile6v so what is the path we are taking implmenting a new plugin or extending the existing plugin 🙂

@Akayeshmantha
Copy link
Member

@membphis @moonming would like to work on this

@agile6v
Copy link
Member Author

agile6v commented May 14, 2020

@agile6v so what is the path we are taking implmenting a new plugin or extending the existing plugin 🙂

Hi @Akayeshmantha Remember that you submitted a proposal at GSOC. How about we follow that plan?

First we implement a simple echo function and then implement a function that modify the response body. For example, adding content before or after the response body.

Thanks.

@Akayeshmantha
Copy link
Member

@agile6v sure think that is a good way to start.

@membphis
Copy link
Member

@agile6v

Can you provide some use cases?
For example, what configuration options are there for this plugin, and the expected execution results?

@agile6v
Copy link
Member Author

agile6v commented May 30, 2020

Hi @Akayeshmantha This example can be used as a reference. Not sure I've made it a clear. If you have any questions, welcome to discuss here.

Thanks.

@Akayeshmantha
Copy link
Member

Akayeshmantha commented May 30, 2020

Hi @agile6v
So you mean we are going to install https://github.com/openresty/echo-nginx-module#installation echo nginx module and use them for the plugin ?

Or are we going with nginx.logging()

@agile6v
Copy link
Member Author

agile6v commented May 30, 2020

Hi @agile6v
So you mean we are going to install https://github.com/openresty/echo-nginx-module#installation echo nginx module and use them for the plugin ?

Or are we going with nginx.logging()

@Akayeshmantha We're going to implement an echo plugin, right? So we refer to its features to implement APISIX's echo plugin?

Thanks.

@moonming
Copy link
Member

moonming commented May 30, 2020

@agile6v you'd better show same specific examples in Apache APISIX

@Akayeshmantha
Copy link
Member

Akayeshmantha commented May 30, 2020

Hi @agile6v so from what I get when it comes to the output_filter phase we should replicate what we have in https://github.com/openresty/echo-nginx-module/blob/master/src/ngx_http_echo_module.c#L412 ?

or simply
function _M.output_filter(conf, ctx)
ngx.var.echo_request_body hello;
end
something like this ?

@agile6v
Copy link
Member Author

agile6v commented May 31, 2020

Hi @Akayeshmantha

We can refer to the implementation of the plugin response-rewrite. It has the ability to override the response body. In the echo plugin we implement the function like this:

function _M.body_filter(conf, ctx)
    conf.before_body + response.body + conf.after_body
end

FYI: https://github.com/openresty/lua-nginx-module#body_filter_by_lua

Hope I've described it clearly.

Thanks.

@Akayeshmantha
Copy link
Member

@agile6v I drafted a small sample can you look in the PR ?

@Akayeshmantha
Copy link
Member

@agile6v @membphis @moonming any idea about how it is now. Can we review it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants