Sinantra,如何在POST处理程序中访问URL params,例如"?something = xyz"(它不在params []中)

jpw*_*ynn 3 param http-post sinatra

我们正在使用第三方Web服务将POSTS多部分数据(文件)发回给我们.但它也通过网址传递额外的参数 http://ourdomain.com/theposturl?extra=good

'filename'对象:filename和:二进制数据的tempfile是params []

但是我们如何从网址中获得"好"呢?

post /theposturl
  puts params.inspect    # this shows a hash with filename, 
                         # :filename and :tempfile as expected

  extra_param = ??????[:extra] # but what lets us 'read' the ?extra=good off the url

end
Run Code Online (Sandbox Code Playgroud)

tha*_*gor 10

您需要使用字符串作为哈希键.

extra_param = params["extra"]
Run Code Online (Sandbox Code Playgroud)