API gateway is an API management tool that sits between a client and a collection of backend services.
Most enterprise APIs are deployed via API gateways. It’s common for API gateways to handle common tasks that are used across a system of API services, such as user authentication, rate limiting, and statistics.
-
Authentication and authorization. A gateway is your first line of defense against potential attackers that can perform basic security functions: antivirus scanning, token translation, decryption and encryption, validation, and many more.
-
Log tracing and aggregation. A gateway keeps detailed audit logs used for debugging, reporting, and analytics.
-
Rate limiting. A gateway enforces policies against resource overuse (either accidental or deliberate) and allows you to configure API invocation at runtime, so the service is consumed only at the required rate.
-
You may have adopted a microservices architecture, in which case a single request could require calls to dozens of distinct applications.
-
Over time you’ll add some new API services and retire others, but your clients will still want to find all your services in the same place.
CREATE TABLE endpoint (
id BIGINT auto_increment PRIMARY KEY,
uri_request VARCHAR(500) NOT NULL,
url_destination VARCHAR(500) NOT NULL,
enable BOOLEAN DEFAULT FALSE,
http_method VARCHAR(4) DEFAULT NULL
);
INSERT INTO endpoint VALUES (1, '/blog/api/user', 'http://localhost:8080/blog/api/user', TRUE, 'GET' );
Example: Request with uri_request "http://localhost:8888/blog/api/user"
will route to url_destination= "http://localhost:8080/blog/api/user"
http://localhost:8888/blog/api/user [GET]
http://localhost:8080/blog/api/user [GET]