This is the first example in the Learn Edge series. In this example, you will deploy a simple API proxy on Apigee Edge. Actually, this is the simplest proxy you can make -- it doesn't actually do anything! But it does return a 200 response to let you know it's deployed properly.
In the next few examples, we'll add features to this proxy.
Be sure to perform the prerequisites if you haven't already.
-
Final reminder: You must have apigeetool installed on your machine, as explained in the prerequisites.
-
cd api-platform-samples/learn-edge/simplest-proxy
. -
./deploy.sh
-
./invoke.sh
This script executes this curl command:
curl http://<your org name>-<your environment>.apigee.net/v1/learn-edge
where "your org name" is the name of your Apigee Edge organization and "your environment" is the name of the environment to deploy to. These values are the ones you set when you first ran
deploy.sh
and were asked to supply configuration settings. -
Look at the output.
Did you get back a Status 200? Perfect! The proxy is deployed and able to accept requests. In proxy-to-a-target, we'll make a few simple changes so the proxy calls an actual backend service.
In every Learn Edge example, we'll remind you to trace API calls in the Edge UI. Here are the basic steps that you'll repeat again and again:
- Log in to your Apigee account.
- Go to APIs->API Proxies.
- Click the proxy named learn-edge.
- In the Overview tab, notice that the Proxy URL is
http://<your org name>-test.apigee.net/v1/learn-edge
. This is the Proxy URL: you will use this URL to call the proxy. - Click the Develop tab. This is the UI-based development environment for proxies.
- Click the Trace tab to go to the Trace Tool.
- Click Start Trace.
- Send a request with the
invoke.sh
script. - Click around the Trace "Transation Map". Notice that in each part of the flow you'll see output showing you information about the request such as headers and message content, any context variables that are read or set during processing, and so on.
Hint: Trace is a valuable tool for debugging proxies. It shows you what's happening while requests and responses pass through the Edge pipeline.
You deployed a basic proxy to Edge, called it, and got a 200 response. This may seem trivial, but you accomplished several important tasks. You deployed an Edge proxy from your work computer to Edge, you called the API proxy, and got back meaningful output. You also poked around the Edge UI and ran a Trace.
-
An API proxy is an API that fronts for another API. In the next example, we'll route a request to a backend target. In later examples, we'll implement policies to enforce security, do caching, fault handling, and much more.
-
This is the basic file structure for all Edge API proxies:
/apiproxy /proxies /targets /policies /resources proxyname.xml
Note that in this "simplest-proxy" example, targets, policies, and resources are empty directories, because they aren't used. In later examples, these other directories, and their contents, will be important.
-
This file structure is mapped into the Edge UI, although the UI uses slightly different names for the components. For example, Policies maps to your local
/policies
directory. Proxy Endpoints maps to the/proxies
directory, and Scripts maps to/resources
.
- Many developers develop proxies locally and deploy them using a command line tool (like
apigeetool
that is used in the./deploy.sh
file) or tools like Maven or Grunt. It's all about properly packaging and uploading the local files to Edge. You can even package a proxy in a ZIP file and upload it through the Edge UI.
The next proxy, proxy-to-a-target, returns data from a backend service.
Copyright © 2016 Apigee Corporation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.