Skip to content

wiliamsouza/apigateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Programmable API gateway micro framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published