If you are unable to append the path, you can alternatively run the Microgateway commands by navigating to the
- Navigate to a preferred workspace folder using the command line.
This location is used to run the Microgateway commands and to generate Microgateway artifacts.
Set up a project using the command given below,
micro-gw setup <project_name> -a <API_name> -v <version>
When the tool requests for the username and password, use
adminin both instances. Use the default values for the other parameters by pressing Enter.
Here is an example:
$ 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.
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,
. └── 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
If you re-run the setup command while you already have a project named
pizzashack-projectin the current working directory, you receive an error similar to the following:
$ 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
$ micro-gw setup pizzashack-project -a PizzaShackAPI -v 1.0.0 -f Enter Password for admin: Setting up project pizzashack-project is successful.
Build the microgateway distribution for the project using the following command:
micro-gw build <project_name>
Here is an example:
$ 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
The name of the distribution will have the format
micro-gw-<project_name>.zip. In the above example, the name will be
Next, unzip the
-project.zipand run the
gatewayshell script inside the
binfolder of the extracted zip using the following command:
The Microgateway will now start for the Pizzashack API. For example,
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