### Navigate to Example Directory Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/6-health-monitor/README.md Change to the health monitor example directory to run the setup. ```bash cd distribution/examples/loadbalancing/6-health-monitor ``` -------------------------------- ### Run Include Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/configuration/include/README.md Navigate to the example directory and run the Membrane script to start the API gateway. ```bash cd examples/configuration/include ./membrane.sh ``` -------------------------------- ### Start Membrane Script Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/openapi/validation/README.md Use this script to start Membrane with the example configuration. Ensure you are using Membrane version 5 or newer. ```shell ./membrane.sh ``` ```batch service.proxy.bat ``` -------------------------------- ### Start Docker Compose Setup Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/monitoring-tracing/prometheus-grafana/README.md Initiates the Membrane, Prometheus, and Grafana services using Docker Compose. ```bash docker compose up ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/2-dynamic/README.md Change to the directory containing the dynamic load balancing example files. ```bash cd examples/loadbalancing/2-dynamic ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/web-services-soap/versioning-soap-xslt/README.md Change your current directory to the example's location. ```shell cd /examples/web-services-soap/versioning-soap-xslt ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/1-static/README.md Change your current directory to the static load balancing example folder. ```bash cd examples/loadbalancing/1-static ``` -------------------------------- ### Start the Router Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/orchestration/for-loop/README.md Start the Membrane router using the provided script. This is the initial step to run any example. ```sh ./membrane.sh # Linux/Mac membrane.bat # Windows ``` -------------------------------- ### Example X-Padding Header Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/padding-header/README.md An example of the X-Padding header that will be present in the response. The content will vary with each request. ```text X-Padding: p,@7;#G=:}vbx`#Rd{wqtA0W;FxM1 ``` -------------------------------- ### Test Membrane Installation Locally Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Send a request to the locally running Membrane API Gateway to verify the installation. ```bash curl -v http://localhost:2000/ ``` -------------------------------- ### Run PostgreSQL Database Container Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/api-key/jdbc-api-key-store/README.md Starts a PostgreSQL database container using Docker. Ensure Docker is installed and running. ```shell docker run --rm --name postgres -e POSTGRES_PASSWORD=secret -p 5432:5432 postgres ``` -------------------------------- ### Start Membrane Service Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Start the Membrane API Gateway service. ```bash sudo systemctl start membrane ``` -------------------------------- ### Start Membrane API Gateway Source: https://github.com/membrane/api-gateway/blob/master/distribution/router/conf/README.md Run Membrane with the configuration in the current folder. Ensure you are in the `membrane-api-gateway-` directory. ```bash cd membrane-api-gateway- ./membrane.sh or ./membrane.cmd ``` -------------------------------- ### Enable Membrane Service on Boot Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Configure the Membrane service to start automatically when the system boots. ```bash sudo systemctl enable membrane ``` -------------------------------- ### Start Membrane with TLS Configuration Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/6-health-monitor/README-TLS.md Use these commands to start the Membrane API Gateway with a specific TLS configuration file. This is necessary for enabling TLS protection. ```bash ./membrane.sh -c proxies-tls.xml ``` ```bash membrane.cmd -c proxies-tls.xml ``` -------------------------------- ### Install yum-utils Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Install the 'yum-utils' package if 'yum-config-manager' is not found. ```bash sudo yum install -y yum-utils ``` -------------------------------- ### Start MongoDB Docker Container Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/mongo-exchange-store/README.md Run this command to start a MongoDB instance in a Docker container. It will be accessible at mongodb://localhost:27017. ```shell docker run --name mongo -p 27017:27017 mongo:latest ``` -------------------------------- ### Start Membrane Router Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/1-static/README.md Execute the Membrane router script to start the load balancer. Use the appropriate script for your operating system. ```bash ./membrane.sh ``` ```bash membrane.cmd ``` -------------------------------- ### Example Response Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/orchestration/call-get/README.md A successful test of the API flow should return a 200 OK status with JSON data representing product details. ```json { "id": 19, "name": "Apple", "price": 5.49, "modified_at": "2025-04-30T04:42:02.548087Z" } ``` -------------------------------- ### Start Membrane Gateway (Linux) Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/json-protection/README.md Starts the Membrane API Gateway using the provided script for Linux environments. ```shell cd examples/security/json-protection ./membrane.sh ``` -------------------------------- ### Run Example with curl Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/routing-traffic/shadowing/README.md Use curl to send a request to the API Gateway and observe the output. This helps verify that the gateway is running and accessible. ```bash curl -v http://localhost:2000 ``` -------------------------------- ### Start Membrane API Gateway Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/web-services-soap/versioning-soap-xslt/README.md Execute the Membrane startup script appropriate for your operating system. ```shell # For Unix/Mac ./membrane.sh # For Windows membrane.cmd ``` -------------------------------- ### Start Membrane Gateway (Windows) Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/json-protection/README.md Starts the Membrane API Gateway using the provided script for Windows environments. ```batch cd examples/security/json-protection membrane.cmd ``` -------------------------------- ### Run Basic Membrane API Gateway Source: https://github.com/membrane/api-gateway/blob/master/distribution/docker/README.md Starts a default Membrane API Gateway instance. Access it via http://localhost:2000. ```bash docker run -p 2000:2000 predic8/membrane ``` -------------------------------- ### AccessControl Configuration in YAML Source: https://github.com/membrane/api-gateway/blob/master/docs/MIGRATION-GUIDE.md Provides examples of the new YAML configuration for 'accessControl', demonstrating inline rules for 'allow' and 'deny' based on IP/hostname. ```yaml api: port: 2000 path: uri: /foo flow: - accessControl: - allow: "^localhost$" ``` ```yaml --- api: port: 2000 path: uri: /bar flow: - accessControl: - deny: 127.0.0.1 - allow: ::1 ``` -------------------------------- ### Client Script Example Output Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/oauth2/api/README.md Illustrates the typical output from the client script, showing the token request to the authorization server and the subsequent call to the protected API with the obtained token. ```text 1.) Requesting Token POST http://localhost:7007/oauth2/token grant_type=password&username=john&password=password&client_id=abc&client_secret=def Got Token: nmsi0fsghcfq3dc9hm064eoq72 2.) Calling API GET http://localhost:2000 Authorization: Bearer nmsi0fsghcfq3dc9hm064eoq72 Got: { "success": true } ``` -------------------------------- ### Configure ApiKeyFileStore globally Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/api-key/rbac/README.md Example of globally registering an ApiKeyFileStore for all apiKey plugins using a component declaration in YAML. ```yaml components: keys: apiKeyFileStore: location: ./demo-keys.txt ``` -------------------------------- ### Run Example with Curl Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/embedding-java/README.md Use curl to send a request to the embedded Membrane API Gateway and observe the added header. ```bash curl -v http://localhost:4000 ``` -------------------------------- ### Build and Run the XML Interceptor Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/xml/basic-xml-interceptor/README.md Use Maven to package your custom interceptor and then run the Membrane server. Send a request to the specified port to see the interceptor in action. ```bash mvn package ``` ```bash curl -d @example.xml http://localhost:2000 -H "Content-Type: application/xml" ``` -------------------------------- ### Log CSV Data Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/logging/console/README.md This is an example of the data logged to the 'log.csv' file. Fields are separated by semicolons. ```csv Status Code;Time;Rule;Method;Path;Client;Server;Request Content-Type;Request Content Length;Response Content-Type;Response Content Length;Duration; 200;2022-12-21 11:00:34.882;:2000;GET;/;localhost;api.predic8.de;;unknown;application/json;336;32; ``` -------------------------------- ### Start Secured Management API Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/3-client/README.md Execute the secured service proxy script to start the management API with encryption enabled. This requires stopping the unsecured router first. ```bash service-proxy-secured.sh ``` -------------------------------- ### Configure ApiKeyFileStore locally Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/api-key/rbac/README.md Example of configuring an ApiKeyFileStore locally within an apiKey plugin in YAML. ```yaml apiKey: ... stores: - apiKeyFileStore: location: ./demo-keys.txt ``` -------------------------------- ### Install Membrane Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Install the Membrane API Gateway package using yum. This also sets up the systemd service and default configuration. ```bash sudo yum install -y membrane ``` -------------------------------- ### JSON Response Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/web-services-soap/rest2soap-template/README.md This is an example of the JSON response you will receive after calling the REST endpoint. ```json { "country": "France", "population": 11346800 } ``` -------------------------------- ### Basic JSON Request Handling Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/if/README.md This example demonstrates a basic POST request with a JSON body. Use this to test default routing or simple plugin logic. ```bash curl -X POST http://localhost:2000 -H "Content-Type: application/json" -d '{"foo": "bar"}' -v ``` -------------------------------- ### Start the Router Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/orchestration/call-authentication/README.md Execute these commands to start the Membrane API Gateway router. Choose the appropriate command based on your operating system. ```sh ./membrane.sh # Linux/Mac ``` ```bat membrane.bat # Windows ``` -------------------------------- ### Large Body Detection Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/if/README.md This example tests how the system handles or routes requests with a large request body. ```bash curl -X POST http://localhost:2000 -d "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -v ``` -------------------------------- ### Start Membrane Router Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/reusable-plugin-chains/README.md Execute these commands to start the Membrane API Gateway router. Choose the appropriate script based on your operating system. ```sh ./router-service.sh # Linux/Mac router-service.bat # Windows ``` -------------------------------- ### Build Docker Image for API Gateway Source: https://github.com/membrane/api-gateway/blob/master/docs/SETUP.md Build the Docker image for the API Gateway. Ensure Docker is installed and running. ```bash docker build . ``` -------------------------------- ### Start Membrane API Gateway (Windows) Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/openapi/jwt-auth/README.md Start the Membrane API Gateway on Windows. This command runs the gateway with the configured token server and protected API. ```bat membrane.cmd ``` -------------------------------- ### Method-Level Documentation for @MCAttribute Source: https://github.com/membrane/api-gateway/blob/master/docs/DEVELOPING.md Document @MCAttribute methods using @description, @default, and @example tags. These populate the attribute table in HTML documentation. ```java /** * @description Target URL. * @default (not set) * @example https://api.example.com */ @MCAttribute public void setTarget(String target) { ... } ``` -------------------------------- ### Start Membrane API Gateway Distribution Source: https://github.com/membrane/api-gateway/blob/master/docs/BUILD.md Extract the distribution ZIP and use the platform-specific startup script to run the gateway. ```sh # Linux/macOS ./membrane.sh ``` ```sh # Windows membrane.cmd ``` -------------------------------- ### Add Membrane Repository Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Add the Membrane repository configuration to your system to enable package installation. ```bash sudo yum-config-manager --add-repo https://membrane.github.io/rpm/unstable/el8/membrane.repo ``` -------------------------------- ### Create JSON with JavaScript Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/scripting/javascript/README.md This example shows how to construct a JSON document from query parameters using JavaScript. The input query parameters are directly mapped into the JSON output. ```bash curl "http://localhost:2000?id=7&city=Berlin" ``` ```json {"id":"7","city":"Berlin"} ``` -------------------------------- ### OpenAPI Server URL Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/openapi/README.md An example of the 'servers' field in an OpenAPI specification. This defines the backend server URL and base path for API requests. ```yaml servers: - url: https://api.predic8.de/shop/v2 ``` -------------------------------- ### Verify Java Version Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md Check if Java 21 or newer is installed and accessible in your PATH. ```bash java -version ``` -------------------------------- ### Query Parameter Check Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/if/README.md These examples demonstrate how to conditionally route or modify requests based on query parameter values. ```bash curl -X GET 'http://localhost:2000/?param1=value1' -v ``` ```bash curl -X GET 'http://localhost:2000/?param1=value2' -v ``` -------------------------------- ### Advanced Routing Examples Source: https://github.com/membrane/api-gateway/blob/master/README.md Demonstrates various advanced routing configurations including blocking POST requests, regex path matching, host-based routing, and query parameter matching. Each configuration uses a fallthrough mechanism, applying only the first matching rule. ```yaml # POST requests api: port: 2000 method: POST flow: - response: - static: src: POST is blocked! - return: status: 405 --- ``` ```yaml # Regex path matching api: port: 2000 path: uri: /shop/v2/products/.* isRegExp: true target: url: https://api.predic8.de --- ``` ```yaml # Requests whose HOST header is "www.predic8.de" api: port: 2000 host: www.predic8.de flow: - response: - static: src: "Homepage" - return: status: 200 --- ``` ```yaml # Requests with a query parameter city and value Paris api: port: 2000 test: params.city?.[0] == 'Paris' flow: - response: - static: src: Oui! - return: status: 200 ``` -------------------------------- ### Run Membrane API Gateway Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/mongo-exchange-store/README.md Execute this command to start the Membrane API Gateway after placing the necessary MongoDB driver JARs in the `lib` directory. ```shell ./membrane.sh ``` -------------------------------- ### Read XML from File and Generate XML Response Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/templating/xml/README.md This example shows how to read XML content from a file and use it to generate a templated XML response. This is useful for more complex XML structures or when data is stored externally. ```bash curl -d @cities.xml -H 'content-type: application/xml' http://localhost:2001 ``` -------------------------------- ### Example Request using curl Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/message-transformation/replace/README.md Send a POST request to the API Gateway to test the Replace plugin. The output shows the modified JSON. ```shell curl localhost:2000 \ -H "Content-Type: application/json" \ -d '{"user": {"name": "Alice", "age": 22}}' ``` -------------------------------- ### Configure API Gateway in XML Source: https://github.com/membrane/api-gateway/blob/master/docs/DEVELOPING.md Example of configuring an API Gateway using XML, mapping to the Java annotations defined previously. ```xml println('Here') ``` -------------------------------- ### Start PostgreSQL Database Container Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/basic-auth/database/README.md Run a PostgreSQL database container using Docker. Ensure to set user and password environment variables and map the default PostgreSQL port. ```shell docker run --name postgres -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres ``` -------------------------------- ### Example Incoming HTTP GET Request Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/web-services-soap/rest2soap/README.md An example of an HTTP GET request sent to the proxy port, which will be intercepted and transformed by the REST2SOAP interceptor. ```http GET /bank/37050198 HTTP/1.1 Host: www.thomas-bayer.com:80 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive X-Forwarded-For: 0:0:0:0:0:0:0:1 ``` -------------------------------- ### Configure OpenTelemetry Plugin Globally Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/monitoring-tracing/opentelemetry/README.md Example configuration for the OpenTelemetry plugin applied globally in `apis.yaml`. This ensures tracing is enabled for all APIs managed by Membrane. ```yaml api: port: 2000 flow: - openTelemetry: sampleRate: 1.0 otlpExporter: host: localhost port: 4317 transport: grpc target: url: http://localhost:2001 ``` -------------------------------- ### Configure Membrane API Gateway with Proxies XML Source: https://github.com/membrane/api-gateway/blob/master/distribution/docker/README.md Starts Membrane API Gateway with a custom configuration file. Mounts a local proxies.xml to the container's configuration directory. ```xml ``` ```bash docker run -v proxies.xml:/opt/membrane/conf/proxies.xml -p 2000:2000 predic8/membrane ``` ```bash docker run -v "$(pwd)/proxies.xml:/opt/membrane/conf/proxies.xml" -p 2000:2000 predic8/membrane ``` -------------------------------- ### Log HTTP Requests and Responses Source: https://github.com/membrane/api-gateway/blob/master/README.md Configure logging for HTTP requests and responses. This example shows logging to the console and generating fine-grained CSV logs. ```yaml api: port: 2000 flow: - log: {} # Logs to the console - statisticsCSV: file: ./log.csv # Logs fine-grained CSV target: url: https://api.predic8.de ``` -------------------------------- ### Header Check for Specific Values Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/if/README.md These examples show how to perform conditional logic based on HTTP request header values. ```bash curl -X GET http://localhost:2000 -H "X-Test-Header: foo" -v ``` ```bash curl -X GET http://localhost:2000 -H "X-Test-Header: foobar" -v ``` -------------------------------- ### Example Membrane Proxy Configuration Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/RHEL/README.md A basic XML configuration for a Membrane API proxy listening on port 2000 and forwarding requests to a target URL. ```xml ``` -------------------------------- ### Create Sample Certificates Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/6-health-monitor/README-TLS.md Scripts to create sample certificates, truststores, and keystores required for TLS communication. These are located in the 'certificates' folder. ```bash create-certificates.sh ``` ```bash create-certificates.cmd ``` -------------------------------- ### URL Rewriting in Membrane API Gateway Source: https://github.com/membrane/api-gateway/blob/master/README.md Rewrite request URLs dynamically before forwarding to the backend. This example rewrites requests starting with '/fruitshop' to '/shop/v2', preserving the rest of the path. ```yaml api: port: 2000 flow: - rewriter: - from: ^/fruitshop/(.*) to: /shop/v2/$1 target: url: https://api.predic8.de ``` -------------------------------- ### Transformation with Computations using Javascript Source: https://github.com/membrane/api-gateway/blob/master/README.md Perform calculations and transformations on input data using Javascript. This example processes items, calculates totals, and formats dates. Ensure the input JSON has the expected structure for 'items' and 'date'. ```yaml api: port: 2000 flow: - request: - javascript: src: | function convertDate(d) { return d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0"+d.getDate()).slice(-2); } ({ id: json.id, date: convertDate(new Date(json.date)), client: json.customer, total: json.items.map(i => i.quantity * i.price).reduce((a,b) => a+b), positions: json.items.map(i => ({ pieces: i.quantity, price: i.price, article: i.description })) }) - return: status: 200 ``` -------------------------------- ### Inline Configuration for api.description in YAML Source: https://github.com/membrane/api-gateway/blob/master/docs/MIGRATION-GUIDE.md Demonstrates the simplified YAML syntax for 'api.description', allowing direct content values instead of nested objects. ```yaml # before api: description: content: Demo Api ``` ```yaml # now api: description: Demo Api ``` -------------------------------- ### Inline Configuration for keyTable in YAML Source: https://github.com/membrane/api-gateway/blob/master/docs/MIGRATION-GUIDE.md Demonstrates the change in YAML configuration for 'keyTable' within 'databaseApiKeyStore', simplifying it to a direct value. ```yaml # before apiKey: stores: - databaseApiKeyStore: keyTable: name: foo ``` ```yaml # now apiKey: stores: - databaseApiKeyStore: keyTable: foo ``` -------------------------------- ### Example CSV Log Output Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/logging/csv/README.md This is an example of the log file content generated by the statisticsCSV plugin. Fields are separated by semicolons. ```text 200;2023-08-30 14:51:25.760;:2000;GET;/shop/v2/;ip6-localhost;null;;unknown;application/json;unknown;613; 200;2023-08-30 16:25:03.501;:2000;GET;/shop/v2/;ip6-localhost;null;;unknown;application/json;unknown;605; ``` -------------------------------- ### JWT Payload Example Source: https://github.com/membrane/api-gateway/blob/master/README.md Example of a JWT payload structure, including header and body, after being signed. This demonstrates the output of the JWT issuance configuration. ```text { "typ": "JWT", "alg": "RS256" } . { "sub": "alice", "iat": 1765222877, "exp": 1765223177 } .hTL_0-AS8IZgiDUJ6Kg... ``` -------------------------------- ### Insert Demo Users into PostgreSQL Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/basic-auth/database/README.md Execute a SQL script to create demo users in the PostgreSQL database. This is necessary for testing the authentication mechanism. ```shell docker exec -i postgres psql -U user -d postgres < ./insert_users.sql ``` -------------------------------- ### Test API Access (/products) Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/access-control-list/README.md Call the `/products` endpoint to test access. This route is allowed specifically for localhost. ```sh curl http://localhost:2000/products ``` -------------------------------- ### Switch to XML Configuration Source: https://github.com/membrane/api-gateway/blob/master/distribution/router/conf/README.md To switch back to XML configuration, remove the 'apis.yaml' file and rename 'proxies.xml.inactive' to 'proxies.xml'. ```bash rm apis.yaml mv proxies.xml.inactive proxies.xml ``` -------------------------------- ### Get Bank Information Source: https://github.com/membrane/api-gateway/blob/master/core/src/test/resources/request.txt This endpoint retrieves bank information using the provided BLZ (Bankleitzahl). ```APIDOC ## POST /axis2/services/BLZService ### Description Retrieves bank information based on the provided Bankleitzahl (BLZ). ### Method POST ### Endpoint /axis2/services/BLZService ### Request Body - **blz** (string) - Required - The Bankleitzahl for which to retrieve information. ### Request Example ```xml 37050198 ``` ### Response #### Success Response (200) - **bankData** (object) - Contains the bank's information. - **name** (string) - The name of the bank. - **bic** (string) - The Bank Identifier Code (BIC). - **city** (string) - The city where the bank is located. #### Response Example ```xml Commerzbank AG COBADEFFXXX Frankfurt ``` ``` -------------------------------- ### SOAP Response Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/web-services-soap/rest2soap/README.md This is the SOAP response received from the target service. It contains the details within a SOAP envelope. ```xml HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 12 May 2011 15:05:17 GMT Sparkasse KölnBonn COLSDE33XXX Köln 50667 ``` -------------------------------- ### Locate Build Artifacts Source: https://github.com/membrane/api-gateway/blob/master/docs/BUILD.md After a successful build, the distribution ZIP and WAR file can be found in their respective target directories. ```sh ../distribution/target/membrane-api-gateway-X.X.X(-SNAPSHOT).zip ../war/target/service-proxy-war-X.X.X(-SNAPSHOT).war ``` -------------------------------- ### Demo Keys File Format Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/security/api-key/apikey-openapi/README.md This file stores API keys and their associated scopes. Each line represents a key, with scopes listed after a colon. Keys without a colon have no associated scopes. ```text # Simple key without any scope 111 # Keys associated with roles/scopes 222: write ``` -------------------------------- ### Run Jaeger Collector Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/monitoring-tracing/opentelemetry/README.md Start a Jaeger all-in-one container with OTLP collector enabled. This is required to receive tracing data from Membrane. ```dockerfile docker run -it --name jaeger -e COLLECTOR_OTLP_ENABLED=true -p 16686:16686 -p 4317:4317 -p 4318:4318 jaegertracing/all-in-one:latest ``` -------------------------------- ### Inline Configuration for publicURL in YAML Source: https://github.com/membrane/api-gateway/blob/master/docs/MIGRATION-GUIDE.md Illustrates the simplified YAML configuration for 'publicURL', allowing direct path values instead of nested objects. ```yaml # before publicURL: publicURL: /foo ``` ```yaml # now publicURL: /foo ``` -------------------------------- ### Clone and Build API Gateway Source: https://github.com/membrane/api-gateway/blob/master/docs/BUILD.md Use this command to clone the repository and build the API Gateway. Tests can be skipped for faster builds. ```sh git clone https://github.com/membrane/api-gateway cd api-gateway mvn install -DskipTests ``` -------------------------------- ### Send Request to Membrane Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/docker/README.md Sends a GET request to the running Membrane container to test its proxy functionality. The request is relayed to api.predic8.de. ```bash curl localhost:2000/shop/v2/products ``` -------------------------------- ### Fetch All Products Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/orchestration/for-loop/README.md This step retrieves a list of products from an upstream service. It uses a URL to specify the endpoint and a limit for the number of products. ```http https://api.predic8.de/shop/v2/products?limit=1000 ``` -------------------------------- ### Sample Request for Search Endpoint Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/message-transformation/transformation-using-javascript/README.md This curl command demonstrates how to query the /search endpoint with pagination parameters. ```bash curl "localhost:2000/search?limit=10&page=2" -v ``` -------------------------------- ### Run Membrane Docker Container Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/deployment/docker/README.md Starts a detached Docker container from the built image and maps port 2000. This command names the container 'membrane'. ```bash docker run -d -p 2000:2000 --name membrane membrane:1 ``` -------------------------------- ### Build Distribution for Development Source: https://github.com/membrane/api-gateway/blob/master/distribution/README.md Use this command for development builds, which skips running tests. ```bash mvn clean install -DskipTests ``` -------------------------------- ### SOAP Request Example Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/web-services-soap/rest2soap/README.md This is the SOAP request sent by Membrane to the target service. It includes the necessary envelope and body structure for a SOAP 1.1 message. ```xml 37050198 ``` -------------------------------- ### Example API Gateway Output Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/routing-traffic/shadowing/README.md The expected JSON output when accessing the API Gateway via curl. This confirms the gateway is serving API information. ```json { "apis": [ { "name": "Shop API Showcase", "description":"API for REST exploration, test and demonstration. Feel free to manipulate the resources using the POST, PUT and DELETE methods. This API acts as a showcase for REST API design.", "url":"/shop/v2/" } ] } ``` -------------------------------- ### Test Membrane API with Curl Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/mongo-exchange-store/README.md Send a POST request to the Membrane API endpoint to test the exchange storage. This example sends a JSON payload. ```shell curl -X POST http://localhost:2000 -H "Content-Type: application/json" -d '{"message": "Hallo"}' ``` -------------------------------- ### Class-Level Documentation with @MCElement Source: https://github.com/membrane/api-gateway/blob/master/docs/DEVELOPING.md Use Javadoc tags to document classes annotated with @MCElement. The @yaml tag is used for embedding example YAML code blocks. ```java /** * @topic 1. Proxies * @description Routes requests to an upstream service. * @yaml *

 *  serviceProxy: {}
 * 
* @deprecated Use FooProxy instead. */ @MCElement(name="serviceProxy") public class ServiceProxy { ... } ``` -------------------------------- ### Register Node with Load Balancer Client Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/3-client/README.md Use the lbclient script to register a node with the load balancer. Ensure the Membrane router is running. ```bash lbclient.sh up localhost 4000 ``` -------------------------------- ### Create JSON with Groovy Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/scripting/groovy/README.md This example shows how to generate a JSON object using a Groovy script. It's useful for creating dynamic responses or data structures. ```json ❯ curl localhost:2000 {"id":7,"city":"Berlin"} ``` -------------------------------- ### JSON Request with Specific Key Check Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/extending-membrane/if/README.md This example tests conditional logic based on the presence and value of a specific key ('name') in the JSON request body. ```bash curl -X POST http://localhost:2000 -H "Content-Type: application/json" -d '{"name": "foo"}' -v ``` -------------------------------- ### Inline Configuration for headerFilter in YAML Source: https://github.com/membrane/api-gateway/blob/master/docs/MIGRATION-GUIDE.md Demonstrates the simplified inline configuration for headerFilter rules in YAML, replacing the previous multi-line structure. ```yaml # before headerFilter: rules: - include: pattern: "X-XSS-Protection" - exclude: pattern: "X-.*" ``` ```yaml # now headerFilter: rules: - include: "X-XSS-Protection" - exclude: "X-.*" ``` -------------------------------- ### Register Node with Secured API (Success with Key) Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/3-client/README.md Register a node with the secured management API after configuring the encryption key in client.properties. This operation should succeed. ```bash lbclient.bat up localhost 4000 ``` -------------------------------- ### Manage Node with Cluster Manager API Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/loadbalancing/2-dynamic/README.md Use curl to interact with the Cluster Manager API to control backend nodes. This example shows how to take a node offline. ```bash curl "http://localhost:9010/clustermanager/down?balancer=default&host=localhost&port=4001" ``` -------------------------------- ### SOAP Request to BLZService Source: https://github.com/membrane/api-gateway/blob/master/core/src/test/resources/request.txt This is an example of a SOAP 1.1 request sent to the BLZService endpoint. It includes standard HTTP headers and a SOAP envelope containing the request payload. ```http POST /axis2/services/BLZService HTTP/1.1 Host: www.thomas-bayer.com:80 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive X-Forwarded-For: 0:0:0:0:0:0:0:1 Content-Length: 237 SOAPAction: Content-Type: text/xml;charset=UTF-8 37050198 ``` -------------------------------- ### Token Server Configuration Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/openapi/jwt-auth/README.md Configure Membrane to act as a token server. This setup issues JWTs with a specified payload, including custom claims like 'scp' for scopes. ```yaml # Token Server api: name: Token Server port: 2000 flow: - request: - template: src: | { "sub": "user@example.com", "aud": "shop", "scp": "inventory" } - jwtSign: jwk: location: jwk.json - return: {} ``` -------------------------------- ### Fetch JSON with Query Parameter Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/templating/json/README.md Use this command to test the JSON templating with a query parameter. The output should be a JSON object. ```bash curl "http://localhost:2000/json?answer=42" ``` -------------------------------- ### Render Final JSON Response Source: https://github.com/membrane/api-gateway/blob/master/distribution/examples/orchestration/for-loop/README.md Construct the final JSON response containing only the 'name' and 'price' for each product. This uses the