简体   繁体   English

在erlang .config文件中配置代理

[英]configure proxy in erlang .config file

Usually I do configure the proxy using: 通常我会使用以下命令配置代理:

httpc:set_options([{proxy, {{"www-proxy.mycompany.com", 8000},
  ["localhost"]}}]).

Is it possible to achieve the same result using the config file? 使用配置文件可以达到相同的结果吗?

Sure you can either use the config file (specified here ) or you can use any .hrl file. 当然,您可以使用配置文件( 在此处指定),也可以使用任何.hrl文件。

The latter option is the one I use, as you can just 后一种选择是我使用的选择,您可以

-include("settings.hrl").

in your file. 在您的文件中。 The settings.hrl file might be looking like this settings.hrl文件可能看起来像这样

-define(PORT, 8080).
-define(URL, "http://my.url").

And in your code you can then use these defines as follows 然后,您可以在代码中使用以下定义

httpc:set_options([{proxy, {{?URL, ?PORT}, ["localhost"]}}]).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM