【发布时间】:2016-08-06 16:34:29
【问题描述】:
我有一个 phoenix req_headers 列表,其中包含 {key, value} 之类的元组。如何通过列表中的键获取元组的值?像这样:
[{"host", "localhost:4000"}, {"user-agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0"}, {"accept", "application/json, text/plain, */*"}, {"accept-language", "en-US,en;q=0.5"}, {"accept-encoding", "gzip, deflate"}, {"content-type", "application/json;charset=utf-8"}, {"referer", "http://localhost:4000/"}, {"content-length", "16"}, {"connection", "keep-alive"}]
我想获取键“host”的值,即“http://localhost:4000”。我该怎么做?
【问题讨论】: