Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 860 Bytes

README.md

File metadata and controls

64 lines (46 loc) · 860 Bytes

apigateway

apigateway is a programmable API gateway micro framework

Features

  • Passthrough
  • Request translator
  • Response translator
  • AWS SNS passthrough
  • AWS SNS request translator

Installation

go get wiliam.dev/apigateway

Tests

make test

Usage

package main

import (
	"log"
	"net/http"
	"net/url"

	"wiliam.dev/apigateway"
)

func main() {
	gateway := apigateway.New()

	target, err := url.Parse("https://ifconfig.co/")
	if err != nil {
		log.Panic("Error parsing target url")
	}
	proxy := apigateway.NewPassthroughReverseProxy(target)

	gateway.Handle("GET", "/myip", proxy)

	log.Fatal(http.ListenAndServe(":8080", gateway.Router()))
}

The above code is a simple passthrough gateway.

curl http://127.0.0.1:8080/myip

Check examples folder for more.