从 mod_esi 或 webtools 中的 Env 检索值
一个完整的菜鸟问题,但我到底如何获取值(例如 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以,这就像我担心的那样令人尴尬......在弄清楚 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...