1
0
Fork
You've already forked api-proxy-go
0
No description
  • Go 100%
Find a file
2026年05月20日 16:06:15 +08:00
.github/workflows update go default go version 2026年05月01日 17:43:17 +08:00
auth Fix token check flow error 2026年05月04日 16:46:52 +08:00
config update config file structure 2026年05月20日 14:01:34 +08:00
http-client remvoe unit test 🦀 🦀 🦀 2026年05月04日 17:17:04 +08:00
http-server log after response 2026年05月20日 16:05:23 +08:00
logger update log data format 2026年05月20日 16:03:55 +08:00
.gitignore update ignored files 2026年05月04日 16:13:49 +08:00
config.toml.example update config file structure 2026年05月20日 14:01:34 +08:00
go.mod require pelletier/go-toml/v2 2026年05月01日 18:00:05 +08:00
go.sum add go.sum 2026年05月01日 18:37:19 +08:00
LICENSE Initial commit 2026年05月01日 16:54:22 +08:00
main.go wait for logger finish before exit 2026年05月20日 16:06:15 +08:00
readme.md add README 2026年05月04日 17:10:55 +08:00

site project.

api-proxy lets you use a simple HTTP request to get target content.

Set listen addess and ports in config.toml:

[server]
address="127.0.0.1"
port=8080

add access token which is allowed:

[auth]
allowAccessTokens = [
 "first-secret-token",
 "another-secret-token",
]

then start the proxy server:

./api-proxy-go

example using curl to make a request:

curl -H 'Authorization: Bearer first-secret-token' \
 http://127.0.0.1:8080 \
 -d '{
 "url":"https://example.org/"
 }'

the proxy server will response the same HTTP status code and response from target web site:

* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
> POST / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/8.5.0
> Accept: */*
> Authorization: Bearer 123456
> Content-Length: 31
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 200 OK
< Date: 2026年5月04日 09:06:11 GMT
< Content-Length: 528
< Content-Type: text/html; charset=utf-8
< 
<!doctype html><html lang="en"><head><title>Example Domain</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style></head><body><div><h1>Example Domain</h1><p>This domain is for use in documentation examples without needing permission. Avoid use in operations.</p><p><a href="https://iana.org/domains/example">Learn more</a></p></div></body></html>
* Connection #0 to host 127.0.0.1 left intact

otherwise, HTTP 500 with an error message will return:

< HTTP/1.1 500 Internal Server Error
< Date: 2026年5月04日 09:07:22 GMT
< Content-Length: 20
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host 127.0.0.1 left intact
invalid access token