gpt4 book ai didi

https - 带有http和https的Webmachine?

转载 作者:行者123 更新时间:2023-12-05 00:04:52 24 4
gpt4 key购买 nike

使用 webmachine 获取 https 的推荐方法是什么?

看到有获取mochiweb的例子working with https and http .我似乎可以将其转换为 webmachine。特别是如何在一个应用程序中处理 http 和 https 请求。

最佳答案

通过在演示应用程序中对 mywebdemo_sup.erl 进行以下更改,我获得了多个听众的成功。我还没有进一步测试它,但希望足以让你开始。

init([]) ->
Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,
{ok, Dispatch} = file:consult(filename:join(
[filename:dirname(code:which(?MODULE)),
"..", "priv", "dispatch.conf"])),
WebConfig = [
{name, one},
{ip, Ip},
{port, 8000},
{log_dir, "priv/log"},
{dispatch, Dispatch}],
Web = {one,
{webmachine_mochiweb, start, [WebConfig]},
permanent, 5000, worker, dynamic},
WebSSLConfig = [
{name, two},
{ip, Ip},
{port, 8443},
{ssl, true},
{ssl_opts, [{certfile, "/tmp/api_server.crt"},
{cacertfile,"tmp/api_server.ca.crt"},
{keyfile, "/tmp/api_server.key"}]},
{log_dir, "priv/log"},
{dispatch, Dispatch}],
WebSSL = {two,
{webmachine_mochiweb, start, [WebSSLConfig]},
permanent, 5000, worker, dynamic},
Processes = [Web, WebSSL],
{ok, { {one_for_one, 10, 10}, Processes} }.

关于https - 带有http和https的Webmachine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5209436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com