A sample API Gateway built in Rust (work in progress) for learning purposes

Overview

rust-api-gateway

A sample API Gateway built in Rust (work in progress) for learning purposes.

You can follow along by reading the tutorial articles:

Part 1: [Implementing a Fully Functional API Gateway in Rust]: (https://medium.com/dev-genius/implementing-a-fully-functional-api-gateway-in-rust-part-1-0eb1d9e8b08e)

Part 2: [Implementing a Dynamic Service Registration] (https://medium.com/@luishrsoares/implementing-a-fully-functional-api-gateway-in-rust-part-ii-dynamic-service-registry-b442728316c5)

This API Gateway is built in Rust and serves as a foundational layer for directing incoming HTTP requests to appropriate services, along with providing several essential features for improving security, observability, and control.

This first version is a rudimentary implementation upon which we will build new features along with tutorials in my Blog at www.luissoares.tech and https://medium.com/@luishrsoares

Table of Contents

Features Setup and Installation Usage Future Enhancements

Features

  1. Routing

    Requests can be routed to different mock services based on the endpoint path. Endpoints like /service1 and /service2 are directed to their respective mock handlers.

  2. Rate Limiting

    Implemented an IP-based rate limiter. Restricts the number of requests from a specific IP address. Responds with "Too many requests" if a limit is exceeded.

  3. Logging

    Logs incoming requests. Displays the source IP address of the requester.

  4. Request & Response Transformation

    Requests: Adds a custom header (X-Custom-Header) before forwarding. Responses: Appends custom JSON data to the responses from the services.

  5. Authentication

    Utilizes JWT-based authentication. Requests must present a valid JWT token in the Authorization header. Validates the token's signature and expected claims.

  6. HTTPS Client

    Can forward requests to HTTPS services.

  7. Error Handling

    Provides appropriate HTTP status codes and error messages for specific scenarios, e.g., missing routes or authentication failures.

  8. Dynamic Service Registry

Setup and Installation - Please, read the articles listed above

Check out some interesting hands-on Rust articles:

🌟 [Implementing a Network Traffic Analyzer] (https://medium.com/@luishrsoares/implementing-a-network-traffic-analyzer-in-rust-50a772bb6564) Ever wondered about the data packets zooming through your network? Unravel their mysteries with this deep dive into network analysis.

🌟 [Building an Application Container in Rust] (https://medium.com/@luishrsoares/implementing-an-application-container-in-rust-3bdde7531ae0) Join us in creating a lightweight, performant, and secure container from scratch! Docker’s got nothing on this. 😉

Stay with us for the next parts, where we’ll uncover even more exciting features and delve deeper into the vast world of microservices with Rust.

Happy coding, and keep those Rust gears turning! 🦀

Read more articles about Rust in my Rust Programming Library!

Visit my Blog for more articles, news, and software engineering stuff!

Follow me on Medium, LinkedIn, and Twitter.

Leave a comment, and drop me a message!

All the best,

Luis Soares

CTO | Tech Lead | Senior Software Engineer | Cloud Solutions Architect | Rust 🦀 | Golang | Java | ML AI & Statistics | Web3 & Blockchain

You might also like...
Revolt backend API server, built with Rust.

Delta Description Delta is a blazing fast API server built with Rust for Revolt. Features: Robust and efficient API routes for running a chat platform

A library to work with CIDRs in rust

ipnetwork This is a library to work with IPv4 and IPv6 CIDRs in Rust Run Clippy by doing rustup component add clippy cargo clippy Installation This c

Modrinth API is a simple library for using Modrinth's API in Rust projects

Ferinth is a simple library for using the Modrinth API in Rust projects. It uses reqwest as its HTTP(S) client and deserialises responses to typed structs using serde.

The Safe Network Core. API message definitions, routing and nodes, client core api.

safe_network The Safe Network Core. API message definitions, routing and nodes, client core api. License This Safe Network repository is licensed unde

Proxy copilot api to openai's gpt-4 api

Proxying Copilot API to OpenAI's GPT-4 API Usage Start the Server export GHU_TOKEN=ghu_xxxx; ./copilot2chat Or sh start.sh start # start the server th

The gRPC library for Rust built on C Core library and futures

gRPC-rs gRPC-rs is a Rust wrapper of gRPC Core. gRPC is a high performance, open source universal RPC framework that puts mobile and HTTP/2 first. Sta

A multiplayer web based roguelike built on Rust and WebRTC
A multiplayer web based roguelike built on Rust and WebRTC

Gorgon A multiplayer web-based roguelike build on Rust and WebRTC. License This project is licensed under either of Apache License, Version 2.0, (LICE

A CLI test program for HNU Cloud Computing Lab 2, built with Rust.

HTTP Server Tester This is a CLI test program for HNU Cloud Computing Lab 2. Install For most student, you don't neet to rebuild this project. We prov

An easy-to-use tunnel to localhost built in Rust. An alternative to ngrok and frp.

rslocal English | 中文 What is rslocal? Rslocal is like ngrok built in Rust, it builds a tunnel to localhost. Project status support http support tcp su

Owner
Luis Soares
Luis Soares
A library-first, lightweight, high-performance, cloud-native supported API gateway🪐 by RUST

Preview version, will not guarantee the stability of the API! Do NOT use in production environment! A library-first, lightweight, high-performance, cl

Ideal World 4 May 7, 2023
Bring the power of pre-signed URLs to your apps. Signway is a gateway for redirecting authentic signed URLs to the requested API

A gateway that proxies signed requests to other APIs. Check the docs for more info. If you are looking for the managed version checkout this link http

Gabriel 37 Jun 24, 2023
A rust-based command line tool to serve as a gateway for a Internet Computer replica.

icx-proxy A command line tool to serve as a gateway for a Internet Computer replica. Contributing Please follow the guidelines in the CONTRIBUTING.md

DFINITY 25 Sep 6, 2022
A Prometheus Aggregation Gateway for FAAS applications

Gravel Gateway Gravel Gateway is a Prometheus Push Gateway for FAAS applications. In particular it allows aggregation to be controlled by the incoming

Colin Douch 85 Nov 23, 2022
Drop-in proxy for Discord gateway connections and sessions allowing for zero downtime deploys

gateway-proxy This is a very hacky project, so it might stop working if Discord changes their API core. This is unlikely, but keep that in mind while

Jens Reidel 39 Nov 26, 2022
A Prometheus Aggregation Gateway for FAAS applications

Gravel Gateway Gravel Gateway is a Prometheus Push Gateway for FAAS applications. In particular it allows aggregation to be controlled by the incoming

Colin Douch 85 Nov 23, 2022
The registration server for WebThings Gateway.

Registration Server This server exposes an HTTP API that lets you register a WebThings Gateway for tunneling support. When combined with a PowerDNS se

WebThings 78 Nov 21, 2022
WireGuard gateway with SNI for portable connectivity.

Gateway This is a daemon that controls gateway servers. Gateway servers are servers that fulfil three major purposes: facilitating connectivity betwee

Fractal Networks 5 Aug 9, 2022
User-space Wireguard gateway allowing sharing network connection from environment where usual routing rules are inaccessible.

wgslirpy A command line tool (and a Rust library) for accepting incoming connections within a Wireguard link and routing them to external network usin

Vitaly Shukela 4 Aug 21, 2023
Super simple tokio chat server for educational purposes.

achat A collection of simple modules which showcase simple use of tasks, channels, and other tokio primitives to implement simple networking applicati

Rafael Bachmann 2 Dec 29, 2022