所以读完之后这个问题 https://stackoverflow.com/questions/389169/best-practices-for-api-versioning关于 API 版本控制,我决定为所有路由添加版本号前缀:
http://localhost/api/1.0/user/login
但是当我在 Exceptions Core 中抛出异常时,它表示路径是:
10/UserControll...
我尝试过逃避这个时期,但这没有用。任何人都可以复制这个问题并想出一个可能的解决方案吗?
这是我用于上述内容的路线:
$route['1.0/user/(:any)'] = '1.0/UserController/$1';
这些是我允许的 URI 字符:
$config['permitted_uri_chars'] = 'a-z 0-9~%\.:_\-';
Open libraries/Input.php (system/core/Input.php in CI version 2.0+) and locate function _clean_input_keys($str){, The whole block should look like so:
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
return $str;
}
检查这是否有“.”在 preg_match 中。
如果不添加它,那么你的正则表达式看起来像这样 -
/^[a-z0-9:_\/-\.]+$/i
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)