Socket
Book a DemoInstallSign in
Socket

wiliam.dev/apigateway

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wiliam.dev/apigateway

Go Modules
Version
v0.0.0-20190620031254-ce5382d1972c
Version published
Created
Source

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.

FAQs

Package last updated on 20 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts