apigateway
所属分类:代理服务器
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2019-06-20 03:13:10
上 传 者:
sh-1993
说明: 可编程API网关微框架,
(Programmable API gateway micro framework,)
文件列表:
Makefile (19, 2019-06-19)
apigateway.go (4280, 2019-06-19)
apigateway_test.go (6712, 2019-06-19)
examples/ (0, 2019-06-19)
examples/passthrough.go (437, 2019-06-19)
examples/request.go (661, 2019-06-19)
examples/response.go (679, 2019-06-19)
go.mod (166, 2019-06-19)
go.sum (1205, 2019-06-19)
apigateway
==========
apigateway is a programmable API gateway micro framework
Features
--------
* Passthrough
* Request translator
* Response translator
* AWS SNS passthrough
* AWS SNS request translator
Installation
------------
```bash
go get wiliam.dev/apigateway
```
Tests
-----
```bash
make test
```
Usage
-----
```go
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.
```bash
curl http://127.0.0.1:8080/myip
```
Check `examples` folder for more.
近期下载者:
相关文件:
收藏者: