玩! 2.0简单的办法,为路由器包罗万象的响应中? [英] Play! 2.0 easy fix to OPTIONS response for router catch-all?

查看:87
本文介绍了玩! 2.0简单的办法,为路由器包罗万象的响应中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有做一些恼人的问题AJAX调用仅仅是因为这几天正在一个OPTIONS调用实际AJAX调用之前的服务器。几乎每一个浏览器

Having some annoying issues making AJAX calls simply because almost every browser these days is making an OPTIONS call to the server before the actual AJAX call.

由于我使用的游戏! 2.0,有没有简单的方法使用OPTIONS方法,使一个通配符响应任何路线?

Since I am using Play! 2.0, is there any easy way to make a wildcard response to any route using the OPTIONS method?

例如,在我的路线做这样的事情: 选项/ * controllers.Options.responseDef

For instance, in my routes do something like: OPTIONS /* controllers.Options.responseDef

的,我知道,新的游戏!没有内置的通配符,但需要有,因为所有的浏览器都日益要求选项之前AJAX调用了一个解决方案。

Yes I am aware that the new Play! doesn't have a wildcard built-in, but there needs to be a solution for this since all browsers are increasingly calling OPTIONS before AJAX calls.

推荐答案

不平静了通配符,位可以使用路线横跨几个斜线段

Not quiet a wildcard, bit you can use a route which spans several slash-segments

OPTIONS   /*wholepath     controllers.Options.responseDef(wholepath)
OPTIONS   /               controllers.Options.responseDef

这应该匹配的所有请求:

It should match all the requests:

OPTIONS    /a
OPTIONS    /a/b
OPTIONS    /a/b/c

请注意:这是从我的头顶,所以也许你需要把它擦亮。我不能由我自己现在检查

Note: that's from the top of my head, so maybe you'll need to polish it. I can't check it now by myself

检查部分动态部分覆盖了手册的若干/

这篇关于玩! 2.0简单的办法,为路由器包罗万象的响应中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆