This documentation is for WSO2 API Manager 2.5.0 View documentation for the latest release.
Page Comparison - Microgateway Quick Start (v.13 vs v.14) - API Manager 2.5.0 - WSO2 Documentation

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed references to toolkit and made minor changes

...

Note

If you are unable to append the path, you can alternatively run the Microgateway commands by navigating to the <MICROGW_TOOLKI_HOME>/bin folder and running the commands as ./micro-gw instead.

...

  1. Navigate to a preferred workspace folder using the command line.
    This location is used to run the Microgateway commands and to generate Microgateway artifacts.
  2. Set up a project using the command given below,

    Code Block
    micro-gw setup <project_name> -a <API_name> -v <version>

    When the tool requests for the username and password, use admin in both instances. Use the default values for the other parameters by pressing Enter

    Here is an example:

    Code Block
    $ micro-gw setup pizzashack-project -a PizzaShackAPI -v 1.0.0
    
    BALLERINA_HOME environment variable is set to /home/user/wso2am-micro-gw-toolkit-2.5.0/lib/platform
    MICROGW_TOOLKIT_HOME environment variable is set to /home/user/wso2am-micro-gw-toolkit-2.5.0
    Enter Username: 
    admin
    Enter Password for admin: 
    
    Enter APIM base URL [https://localhost:9443/]: 
    
    Enter Trust store location: [lib/platform/bre/security/ballerinaTruststore.p12]
    
    Enter Trust store password: [ use default? ]
    
    Setting up project pizzashack-project is successful.
    Note

    When the above command is issued, the tool connects with API Manager REST APIs and retrieves the API specified above. The source artifacts are generated in the current folder location.

    The folder structure looks similar to the following,

    Code Block
    .
    └── pizzashack-project
        ├── conf
        │   └── labeldeployment-config.toml
        ├── src
        │   ├── endpointsextension_filter.bal
        │   ├── extension_filterlisteners.bal
        │   ├── PizzaShackAPI_1_0_0.bal
        │   └── policies
        │       ├── application_10PerMin.bal
        │       ├── application_20PerMin.bal
        │       ├── ...
        │       ├── subscription_Bronze.bal
        │       ├── subscription_Gold.bal
        │       ├── ...
        │       ├── subscription_Unauthenticated.bal
        │       └── throttle_policy_initializer.bal
        └── target
    Note

    If you re-run the setup command while you already have a project named pizzashack-project in the current working directory, you receive an error similar to the following:

    Code Block
    $ micro-gw setup pizzashack-project -a PizzaShackAPI -v 1.0.0
    
    [micro-gw: Project name `pizzashack-project` already exist. use -f or --force to forcefully update the project directory., Run 'micro-gw help' for usage.]

    As suggested in the above output, if you need to override the current project, run the setup command with the -f (--force)option.

    Code Block
    $ micro-gw setup pizzashack-project -a PizzaShackAPI -v 1.0.0  -f
    
    Enter Password for admin: 
    
    Setting up project pizzashack-project is successful.
  3. Build the microgateway distribution for the project using the following command:

    Code Block
    micro-gw build <project_name>

    Here is an example:

    Code Block
    $ micro-gw build pizzashack-project
    
    BALLERINA_HOMEBuild environmentsuccessful variablefor isthe set to /home/user/wso2am-micro-gw-toolkit-2.5.0/lib/platform
    MICROGW_TOOLKIT_HOME environment variable is set to /home/user/wso2am-micro-gw-toolkit-2.5.0
    Build successproject - pizzashack-project

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

    The name of the distribution will have the format micro-gw-<project_name>.zip. In the above example, the name will be micro-gw-pizzashack -project.zip.

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

    Code Block
    bash gateway

    The Microgateway will now start for the Pizzashack API. For example,

    Code Block
    micro-gw-pizzashack-project/bin$ bash gateway
    
    ballerina: HTTP access log enabled
    ballerina: initiating service(s) in '/home/user/workspace/pizzashack-project/target/micro-gw-pizzashack-project/exec/pizzashack-project.balx'
    2018-07-26 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

...