custom-api-gateway

module
v0.0.0-...-a294835 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2021 License: MIT

README

Custom API Gateway

This is a lightweight API Gateway and Management Platform that enables you to control who accesses your API, when they access it and how they access it. It is forked from the precious work by MotivLabs.

Contrary to the original Janus implementation, this one is more opinionated:

  • This fork is meant to be used only as a Docker container.

  • Strictly uses Prometheus for metrics.

  • Strictly uses Jaeger (Adding up OpenTelemetry is still an option, but not yet).

What is an API Gateway?

An API Gateway sits in front of your application(s) and/or services and manages the heavy lifting of:

  • authorization,
  • access control, and
  • rate limiting to your services.

Ideally, it should mean that you can focus on creating services instead of implementing management infrastructure. For example, if you have written a really awesome web service that provides geolocation data for all the cats in NYC, and you want to make it public, integrating an API gateway is a faster, more secure route than writing your own authorisation middleware.

Key Features

This API Gateway offers powerful, yet lightweight features that allows fine-grained control over your API ecosystem.

  • No dependency hell, single binary made with go
  • REST API, full programatic access to the internals makes it easy to manage your API users, keys and API Configuration from within your systems
  • Hot-reloading of configuration. No need to restart the process
  • Graceful shutdown of http connections
  • OpenTracing support for Distributed tracing (Supports Google Cloud Platform and Jaeger)
  • HTTP/2 support
  • Circuit Breaker support that can be configured for each API
  • Retry mechanism to make your endpoints more resilient
  • Rate Limiting, easily rate limit your API users, rate limiting is granular and can be applied on a per-key basis
  • CORS Filter, enable cors for your API, or even for specific endpoints
  • Multiple auth protocols, out of the box, we support JWT, OAuth 2.0 and Basic Auth access methods
  • Small official docker image included

Linting

golangci-lint is used for linting.

On macOS, it can be installed thru 🍺 (i.e. brew install golangci-lint) and can be run with:

golangci-lint run

Installation

Docker

The way of installing Custom API Gateway is to run the docker image for it. You can check our examples folder and you can find some good examples. All you got to do is:

cd examples/front-proxy

docker-compose up -d

Now you should be able to get a response from the gateway.

Try the following command:

http http://localhost:8081

Contributing

To start contributing, please check CONTRIBUTING.

Directories

Path Synopsis
Package cassandra is for Cassandra connection sessions
Package cassandra is for Cassandra connection sessions
wrapper
Package wrapper is a Cassandra wrapper
Package wrapper is a Cassandra wrapper
cmd
features
pkg
api
Package api holds the models for the API Definition.
Package api holds the models for the API Definition.
config
Package config provides the configuration for Janus.
Package config provides the configuration for Janus.
errors
Package errors provides a nice way of handling http errors Examples: To create an error: err := errors.New(http.StatusBadRequest, "Something went wrong")
Package errors provides a nice way of handling http errors Examples: To create an error: err := errors.New(http.StatusBadRequest, "Something went wrong")
jwt
jwt/basic
Package basic is for JWT basics.
Package basic is for JWT basics.
jwt/github
Package github has GitHub configurations for JWT tokens
Package github has GitHub configurations for JWT tokens
jwt/provider
Package provider I dunno
Package provider I dunno
logging
Package logging initializes zap logger.
Package logging initializes zap logger.
metrics
Package metrics creates a metric context
Package metrics creates a metric context
middleware
Package middleware contains middlewares
Package middleware contains middlewares
observability
Package observability is for Prometheus
Package observability is for Prometheus
plugin/basic/encrypt
Package encrypt is for hashing.
Package encrypt is for hashing.
proxy/balancer
Package balancer provides a simple interface to create concrete balancer algorightms that can be used to choose an upstream
Package balancer provides a simple interface to create concrete balancer algorightms that can be used to choose an upstream
render
Package render is for JSON
Package render is for JSON
router
Package router is a Chi router for now
Package router is a Chi router for now
test
Package test for what?
Package test for what?
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL