You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/06/15 17:50:11 UTC

[GitHub] [incubator-apisix] Akayeshmantha commented on a change in pull request #1708: feature(echo): support header filter and access phases.

Akayeshmantha commented on a change in pull request #1708:
URL: https://github.com/apache/incubator-apisix/pull/1708#discussion_r440345136



##########
File path: apisix/plugins/echo.lua
##########
@@ -70,4 +92,21 @@ function _M.body_filter(conf, ctx)
     ngx.arg[2] = true
 end
 
+function _M.header_filter(conf, ctx)
+    if conf.headers_arr then
+        local field_cnt = #conf.headers_arr
+        for i = 1, field_cnt, 2 do
+            ngx.header[conf.headers_arr[i]] = conf.headers_arr[i+1]
+        end
+    end
+end
+
+function _M.access(conf, ctx)
+    local auth_header = ngx.headers["Authorization"]
+    if not auth_header then
+        return 401, { message = conf.unathorized_body }
+    end
+    return 200, { message = conf.authorized_body }

Review comment:
       @agile6v  you mean like we do in the basic-auth plugin extract the values and check ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org