3 Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
19 local BasePlugin = require "plugins.base_plugin"
21 local SamplePluginHandler = BasePlugin:extend()
23 function SamplePluginHandler:new()
24 SamplePluginHandler.super.new(self, "sampleplugin")
27 function SamplePluginHandler:access()
28 SamplePluginHandler.super.access(self)
29 --[[more about the use of APIs please refer to github doc
30 https://github.com/openresty/lua-nginx-module
32 --validate and rewrite
33 if(ngx.req.get_method() == "GET") then
34 ngx.req.set_uri("/sayhello")
35 ngx.var.backend = "127.0.0.1:10089"
37 ngx.status = ngx.HTTP_NOT_ALLOWED
42 local client_ip = ngx.var.remote_addr
43 if(client_ip ~= "127.0.0.1") then
44 ngx.status = ngx.HTTP_FORBIDDEN
50 return SamplePluginHandler