我有一个wai / warp应用程序。我该如何处理邮寄申请?我有这个:
app :: Application
app request respond =
respond $ case rawPathInfo request of
"/" -> responseFile status200 ............
"/some_post_req/" -> .....
如何指定some_post_req
必须是POST?
答案 0 :(得分:1)
应该像将s=requests.Session()
proxy_url=os.environ['HTTPS_PROXY']
s.proxies["https"]=proxy_url
# have to specify proxy here because env variable is only detected by httplib code
#while we need to trigger requests' proxy logic that acts earlier
# "https" means any https host. Since a Session persists cookies,
#it's meaningless to make requests to multiple hosts through it anyway.
pm=s.get_adapter("https://").proxy_manager_for(proxy_url)
pm.proxy_headers['Host']="host.com"
del pm,proxy_url
<...>
s.get('https://host.com')
与Network.Wai.requestMethod
的结果进行比较一样简单:
Network.Wai.methodPost
由于app request respond
| requestMethod request == methodPost
= respond $ case rawPathInfo request of
{- handle POST routes -}
| otherwise
= {- handle other request methods -}
,methodPost
和&amp; c。都有常量,您可以使用它们,但methodGet
是Method
的别名,所以你也可以使用ByteString
扩展程序:
OverloadedStrings
然后与字符串文字进行比较:
{-# LANGUAGE OverloadedStrings #-}
或模式匹配:
requestMethod request == "POST"
答案 1 :(得分:0)