WSO2 Microgateway with Custom Filter Extensions

Request Interceptor: x-wso2-request-interceptorResponse Interceptor: x-wso2-response-interceptor
micro-gw init <project_name>Eg: micro-gw init SAMPLE_PROJECT
Project Initialization — WSO2 Microgateway Toolkit 3.2.0
Eg: <MGW_TOOLKIT_HOME>/bin/SAMPLE_PROJECT/extensions
import ballerina/http;public type TestFilter object {public function filterRequest(http:Caller caller, http:Request request, http:FilterContext context) returns boolean {return true;}public function filterResponse(http:Response response, http:FilterContext context) returns boolean {return true;}};
public function filterRequest(http:Caller caller, http:Request request, http:FilterContext context) returns boolean {request.setHeader("customRequestHeader1", "Value1");return true;}
public function filterResponse(http:Response response, http:FilterContext context) returns boolean {response.setHeader(“customResponseHeader1”, “Value2”);return true;}
import ballerina/http;public type TestFilter object {public function filterRequest(http:Caller caller, http:Request request, http:FilterContext context) returns boolean {request.setHeader(“customRequestHeader1”, “Value1”);return true;}public function filterResponse(http:Response response, http:FilterContext context) returns boolean {response.setHeader(“customResponseHeader1”, “Value2”);return true;}};
Eg: <MGW_TOOLKIT_HOME>/bin/SAMPLE_PROJECT/conf
[[filters]]
name = “TestFilter”
position = 1
micro-gw build <PROJETC_NAME>Eg: micro-gw build SAMPLE_PROJECT
Project build — WSO2 Microgateway Toolkit 3.2.0
gateway <PATH_TO_JAR_FILE>/<RUNTIME_ARTIFACT_NAME>.jarEg: gateway /home/sumudu/Documents/wso2_workspace/wso2_products/wso2am-micro-gw-toolkit-linux/3.2.0/wso2am-micro-gw-toolkit-linux-3.2.0/bin/SAMPLE_PROJECT/target/SAMPLE_PROJECT.jar
API Deployed in Runtime — WSO2 Microgateway Runtime 3.2.0
API Invocation
Client request in Webhook.site
[b7a.http]
[b7a.http.tracelog]
console = true
gateway <PATH_TO_JAR_FILE>/<RUNTIME_ARTIFACT_NAME>.jarEg: gateway /home/sumudu/Documents/wso2_workspace/wso2_products/wso2am-micro-gw-toolkit-linux/3.2.0/wso2am-micro-gw-toolkit-linux-3.2.0/bin/SAMPLE_PROJECT/target/SAMPLE_PROJECT.jar
gateway <PATH_TO_JAR_FILE>/<RUNTIME_ARTIFACT_NAME>.jar --b7a.http.tracelog.console=trueEg: gateway /home/sumudu/Documents/wso2_workspace/wso2_products/wso2am-micro-gw-toolkit-linux/3.2.0/wso2am-micro-gw-toolkit-linux-3.2.0/bin/SAMPLE_PROJECT/target/SAMPLE_PROJECT.jar--b7a.http.tracelog.console=true

Part 1: Inbound Request

Inbound Request — WSO2 Microgateway Runtime 3.2.0

Part 2: Outbound Request

Outbound Request — WSO2 Microgateway Runtime 3.2.0

Part 3: Inbound Response

Inbound Response — WSO2 Microgateway Runtime 3.2.0

Part 4: Outbound Response

Outbound Response — WSO2 Microgateway Runtime 3.2.0
[[filters]]
name = “TestFilter”
position = 1
Source : https://mg.docs.wso2.com/en/latest/how-tos/extensions/custom-filters/#how-to-add-a-custom-filter

--

--

--

Senior Software Engineer @ WSO2 | 2nd Runner-Up of WSO2 Certified Employee of the Year — 2021 | 10X WSO2 Certified | BIT(UCSC) | DiHN | OCPJP

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My Journey Into Coding

AZ-900 certification free learning resources

Town Carpet 6/18

Women participation in software development in Africa

CS371p Spring 2022 Week 1/24–1/30: Tejas Karuturi

Manual Testing

Introducing Flex Pattern

#amsterdam #punk #na http://ift.tt/2jXcf1Q

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sumudu Sahan Weerasuriya

Sumudu Sahan Weerasuriya

Senior Software Engineer @ WSO2 | 2nd Runner-Up of WSO2 Certified Employee of the Year — 2021 | 10X WSO2 Certified | BIT(UCSC) | DiHN | OCPJP

More from Medium

Keycloak Social Login with Custom Login Page

Deploy a secure Web Application in Amazon Beanstalk with SSl certificate and custom domain name

Introduction to Application Framework

JWT Keys and RingCentral API Connections