Build an API Gateway REST API with HTTP Integration
Last Updated :
28 Mar, 2023
Pre-requisite: AWS
We can use either the HTTP proxy integration or the HTTP custom integration to build an API using HTTP integration. When feasible, leverage HTTP proxy integration for faster API setup while delivering varied and strong functionality. If it is essential to change client request data for the backend or backend response data for the client, HTTP custom integration might be appealing.
HTTP proxy integration is a simple, powerful, and adaptable way of creating an API that allows a web application to access numerous resources or features of the integrated HTTP endpoint, such as the full website, using a single API call. API Gateway sends the client-submitted method request to the backend via HTTP proxy integration. Request headers, query string parameters, URL path variables, and payload are all part of the request data that is passed through. The backend HTTP endpoint, often known as the web server, parses the incoming request data to determine the answer. Except for known limitations such as unsupported characters, which are noted in Amazon API Gateway's important notes, HTTP proxy integration allows the client and backend to connect directly with no interference from API Gateway when the API method is set up.
You can use an HTTP proxy integration to establish an API of a single API method using the all-encompassing proxy resource {proxy+} and the catch-all ANY verb for the HTTP method. The method exposes a website's whole collection of publicly available HTTP resources and actions. When the backend web server makes more resources available to the public, the client can use them using the same API configuration.
The following lesson serves as an overview of HTTP proxy integration. In this tutorial, we will construct an API using the API Gateway interface to interact with the PetStore website using a generic proxy resource {proxy+} and the HTTP method placeholder ANY.
Steps To Build an API with HTTP Proxy Integration with the PetStore Website through a Proxy Resource
Step 1: Access the API Gateway console by going AWS console.
Step 2: Choose Build from the REST API menu. Choose OK when the Create Example API box displays.
Step 3: Choose New API.
Step 4: Enter a name in the API Name.
Step 5: Add a brief description in the Description field if desired.
Step 6: Click Create API.
Step 7: Pick a parent resource item from the Resources tree and then choose to Create Resource from the Actions drop-down menu to create a child resource.
Step 8: To create a proxy resource, select the Configure as proxy resource option.
Step 9: Use the default name proxy in the Resource Name input text field.
Step 10: Use the default name /{proxy+} in the Resource Path input text field.
Step 11: Select Enable API Gateway CORS.
Step 12: Click Create Resource.
Step 13: Choose ANY from the HTTP method drop-down list, then click the check mark button to preserve your selection.
Step 14: Choose HTTP Proxy for Integration type.
Step 15: use http://petstore-demo-endpoint.execute-api.com/{proxy} for the Endpoint URL.
Step 16: Use default settings for other fields and click Save to finish configuring the ANY method.
The API's proxy resource path of {proxy+} becomes the placeholder of any of the backend endpoints under http://petstore-demo-endpoint.execute-api.com/ in the newly established API. For example, It can be a pet store, pet store/pets, or the pet store/pets/{petId}. At runtime, the ANY method acts as a placeholder for any of the available HTTP verbs.
Steps To Test an API with HTTP Proxy Integration
Step 1: In the Resources tree, choose ANY on a proxy resource.
Step 2: In the Method Execution window, select Test.
Step 3: Choose to GET from the Method drop-down list.
Step 4: In place of the proxy resource path ({proxy}), use pet store/pets for Path and type=fish for Query Strings.
Step 5: Leave other settings as it is.
Step 6: Click Test to test invoking the method.
Step 7: Because the backend website accepts the GET /pet store/pets?type=fish request, it returns the following successful response:
Step 8: If you attempt to call GET /pet store, you will receive a 404 response with the error message Cannot GET /pet store. This is because the provided operation is not supported by the backend. Because the PetStore website supports GET /pet store/pets/1, you will receive a 200 OK response with the following payload.
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i
6 min read
Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc
15+ min read