This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Grouping APIs with Labels

This documentation is for the API Microgateway component that is coupled with WSO2 API Manager 2.6.0.
View the documentation for the latest release - WSO2 API Microgateway 3.0.2.

It is possible to create a Microgateway distribution for a group of APIs. In order to group APIs, a label needs to be created and attached to the APIs that need to be in a single group.

Creating and attaching a Microgateway to an API

  1. Log in to the Admin portal ( https://<hostname>:9443/admin). Use admin as the username and password. 

  2. To add a new Microgateway label, click LABELS under MICROGATEWAY, and then click ADD MICROGATEWAY.
  3. Create a new label (e.g. MARKETING_STORE), add a host (e.g. https://localhost:9095) and click Save.


  4. Navigate to the API Publisher (https://<hostname>:9443/publisher). Sign in using admin as the username and password. 
  5. Deploy the sample Pizzashack API by clicking Deploy Sample API if you have not already done.
  6. Choose to edit the created Pizzashack API.

  7. Navigate to the Manage section and click Gateway Environments. 

  8. Select the newly created label to attach it to the Pizzashack API.
  9. Click  Save & Publish.
  10. Similarly, you can select MARKETING_STORE label for few other Published APIs.

Generating a Microgateway distribution for a label

  1. Run the initial setup command for the MARKETING_STORE label after navigating to a preferred workspace folder.

    micro-gw setup <project name> -l <label name> 

    Here is a sample:

    micro-gw setup marketing_project -l MARKETING_STORE 
  2. Build the microgateway distribution for the project using the following command:

    micro-gw build marketing_project

    Once the above command is executed, the generated source files are built and a Microgateway distribution is created under the target folder.

  3. Next, unzip the micro-gw-marketing-project.zip and run the gateway shell script inside the bin folder of the extracted zip using the following command:

    bash gateway 

    The Microgateway starts for the APIs grouped with MARKETING_STORE label you just created. 

    micro-gw-marketing-project/bin$ bash gateway
    
    ballerina: HTTP access log enabled
    ballerina: initiating service(s) in '/home/user/workspace/marketing-project/target/micro-gw-marketing-project/exec/marketing-project.balx'
    2018-06-29 21:16:44,142 INFO  [wso2/gateway:0.0.0] - Subscribing writing method to event stream 
    ballerina: started HTTPS/WSS endpoint 0.0.0.0:9096
    ballerina: started HTTPS/WSS endpoint 0.0.0.0:9095
    ballerina: started HTTP/WS endpoint 0.0.0.0:9090
    
    

Viewing Microgateway labels in the API Store

  1. Log in to the API Store ( https://<hostname>:9443/store). Use admin as the username and password.
  2. Any attached Microgateways are shown in the Overview tab of the API.