从 mod_esi 或 webtools 中的 Env 检索值

发布于 2024-08-26 01:27:43 字数 548 浏览 5 评论 0原文

一个完整的菜鸟问题,但我到底如何获取值(例如 path_info) 从回调内部?从文档中,我认为这是 元组列表,我认为可以通过以下方式访问它 列表:keyfind,但我没有运气。到目前为止,我所举的所有例子 发现仅显示如何使用 io_lib 打印所有内容,但不显示如何 通过键访问值...

谢谢, --tim

文档:

模块:函数(SessionID,Env,输入)-> _

Types
    SessionID = term()
    Env = [EnvironmentDirectives] ++ ParsedHeader
    EnvironmentDirectives = {Key, Value}
    Key = query_string | content_length | server_software | gateway_interface | server_protocol | server_port | request_method | remote_addr | script_name. <v>Input = string()

A complete noob question, but how exactly do I get values (e.g.
path_info) from inside the callback? From the docs, I thought it was
a list of tuples, which I thought would make it accessible via
lists:keyfind, but I've had no luck. So far, all the examples I've
found only show how to print everything with io_lib but not how to
access the values by key...

Thanks,
--tim

The docs:

Module:Function(SessionID, Env, Input)-> _

Types
    SessionID = term()
    Env = [EnvironmentDirectives] ++ ParsedHeader
    EnvironmentDirectives = {Key, Value}
    Key = query_string | content_length | server_software | gateway_interface | server_protocol | server_port | request_method | remote_addr | script_name. <v>Input = string()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯了 2024-09-02 01:27:43

所以,这就像我担心的那样令人尴尬......在弄清楚 debug_info 编译器标志前面有一个 + 而不是 - 之后,我发现它实际上是一个元组列表。我的问题与我尝试将其打印出标准输出有关 - 不喜欢该元组并且挂起。无论如何,

列出:keyfind(path_info,1,Env)。
-> {path_info,"/some/path"}

现在,继续这个学习 erlang 的谦卑之旅......

So, it is as embarrassing as I feared... after figuring out there's a + in front of the debug_info compiler flag instead of a -, I was able to figure out that it is in fact a list of tuples. My problem had to do with my attempting to print it out stdout - didn't like the tuple and was hanging. Anyway,

lists:keyfind(path_info,1,Env).
-> {path_info,"/some/path"}

Now, to continue this humbling journey that is learning erlang...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文