Allow Web apps to call APIs by adding Cross-Origin Resource Sharing(CORS) support for them.
+---------+ +-----------+ +---------+ | | +------> | | +-----> | | | Web App | | API Proxy | | Web API | | | <------+ | | <-----+ | | +---------+ CORS +-----------+ +---------+
The APIs can be configured in config.toml
file usingTOML syntax.
API url is a template string defined by RFC6570 - URI Template , for example:
[Api.GetIpInfo] url = "http://ip.taobao.com/service/getIpInfo.php{?ip}" params = ["ip"] format = "json"
is converted to:
http://ip.taobao.com/service/getIpInfo.php?ip=127.0.0.1
by given:
http://your.proxy.ip.or.domain/GetIpInfo?ip=127.0.0.1
pacman -S rustup rustup install nightly rustup default nightly cargo run
git clone https://github.com/emk/rust-musl-builder.git cd rust-musl-builder docker build --build-arg TOOLCHAIN=nightly -t rust-musl-builder . alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src rust-musl-builder' cd ApiProxy rust-musl-builder cargo build --release docker build -t apiproxy . docker run -v "$(pwd)/config":/ApiProxy/config -p 6767:6767 apiproxy
docker pull liujf/apiproxy