proxy跨域不生效_ApiProxy:专治不支持跨域访问的 Web API

ApiProxy

Allow Web apps to call APIs by adding Cross-Origin Resource Sharing(CORS) support for them.

+---------+ +-----------+ +---------+

| | +------> | | +-----> | |

| Web App | | API Proxy | | Web API |

| |

+---------+ CORS +-----------+ +---------+

Usage

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

Run code

pacman -S rustup

rustup install nightly

rustup default nightly

cargo run

Build and run docker image

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

Pull from docker hub

docker pull liujf/apiproxy

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值