https://github.com/beono/simproxy
simple proxy – example of an application that uses reverse proxy from the standartd library
https://github.com/beono/simproxy
api example go golang proxy proxy-server
Last synced: 16 days ago
JSON representation
simple proxy – example of an application that uses reverse proxy from the standartd library
- Host: GitHub
- URL: https://github.com/beono/simproxy
- Owner: beono
- License: mit
- Created: 2018-01-01T13:06:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T21:33:31.000Z (almost 8 years ago)
- Last Synced: 2024-06-20T07:56:08.913Z (over 1 year ago)
- Topics: api, example, go, golang, proxy, proxy-server
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/beono/simproxy)
[](https://godoc.org/github.com/beono/simproxy)
[](https://goreportcard.com/report/github.com/beono/simproxy)
# About the project
The project is an example of an application that uses reverse proxy from the standartd library.
# Why
Let's assume you want to migrate your api from language X to golang.
Sometimes it's hard to rewrite everything at once and you want to move some handlers to golang, but use old application as a fallback.
I just want to show you that you don't have to use any 3rd-party proxies (like `nginx`) or write your own proxy logic.
# How to use it
The solution is quite simple and straightforward.
We use [reverse proxy](https://golang.org/pkg/net/http/httputil/#NewSingleHostReverseProxy) and http server from the standard library.
* Clone or `go get -u github.com/beono/simproxy` this project.
* Run `go test && go run main.go` to see it in action.
Send a request to http://localhost/hello and you will get a tiny text response.
Send a request to http://localhost:8080/oauth2/v3/certs and you will get a json response.
This request was proxied to https://www.googleapis.com/oauth2/v3/certs, because this handler doesn't exist in our new application.