-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathuse_proxy.go
More file actions
26 lines (23 loc) · 790 Bytes
/
use_proxy.go
File metadata and controls
26 lines (23 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// # Api Proxy
//
// ## Purpose:
// Provides a fast, intermediate server to conceal your api keys when proxying
// to an api
//
// ## Inputs:
// 1. PORT: which port to run on ( e.g. 8080 )
// 2. URL_ROOT: the destination root url ( e.g. http://foo.com/api/ )
// 3. URL_SUFFIX: the query params you wish to transparently append to the each
// request. ( e.g. a suffix of "language=en&key=XXXXXX" would result in the
// url http://foo.com/test?name=bob being requested transparently as
// http://foo.com/test?name=bob&language=en&key=XXXXXX )
package main
import (
"github.com/semanticart/simpleapiproxy/apiproxy"
"net/http"
"os"
)
func main() {
apiProxy := apiproxy.Proxy(os.Getenv("URL_ROOT"), os.Getenv("URL_SUFFIX"))
http.ListenAndServe(":"+os.Getenv("PORT"), apiProxy)
}