gateway

package module
v0.0.0-...-869f800 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 0

README

Gateway Proxy

Package gateway provides a simple reverse proxy server that can switch between two backends based on the response of the first one.

Overview

The gateway package offers functionality to create a reverse proxy server capable of routing requests to two different backend servers (A and B).
It dynamically switches between the backends based on the response received from the initial request to A.
If A responds with a 404 error and a special header indicating a fallback route, subsequent requests are routed to B.

Note: Routes are cached for performance. To reset the cache, you must restart the server.

Features

  • Dynamic Routing: The server dynamically switches between two backend servers based on the response from the initial request.
  • Fallback Mechanism: If the primary backend (A) returns a 404 error with a specific header indicating a fallback route, subsequent requests are routed to the secondary backend (B).
  • Route Caching: Routes are cached for performance. To reset the cache, you must restart the server.

License

This project is licensed under the MIT License.

Documentation

Overview

Package gateway provides a simple reverse proxy server that can switch between two backends based on the response of the first one.

Index

Constants

View Source
const HeaderNoRoute = "X-No-Route"

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(aURL, bURL string, logger *pine.Logger) (*Server, error)

func (*Server) Run

func (s *Server) Run(port string)

func (*Server) Shutdown

func (s *Server) Shutdown()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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