本文整理汇总了PHP中Slim\App::options方法的典型用法代码示例。如果您正苦于以下问题:PHP App::options方法的具体用法?PHP App::options怎么用?PHP App::options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\App
的用法示例。
在下文中一共展示了App::options方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(App &$app)
{
$self = $this;
$app->post('/raids', function (Request $request, Response $response) use(&$self) {
return $self->responseRaids($request, $response)->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Content-type', 'application/json');
});
$app->options('/raids', function (Request $request, Response $response, $args) use(&$self) {
return $response->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Access-Control-Allow-Headers', 'Content-Type, X-AUTH-USER, X-AUTH-TOKEN');
});
$app->post('/raids/add', function (Request $request, Response $response) use(&$self) {
return $self->responseRaidsAdd($request, $response)->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Content-type', 'application/json');
});
$app->options('/raids/add', function (Request $request, Response $response, $args) use(&$self) {
return $response->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Access-Control-Allow-Headers', 'Content-Type, X-AUTH-USER, X-AUTH-TOKEN');
});
}
示例2: register
public function register(App &$app)
{
$self = $this;
$app->post('/login', function (Request $request, Response $response) use(&$self) {
return $self->responseLogin($request, $response)->withHeader('Content-type', 'application/json')->withHeader('Access-Control-Allow-Origin', '*');
});
$app->options('/login', function (Request $request, Response $response, $args) use(&$self) {
return $response->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Access-Control-Allow-Headers', 'Content-Type');
});
$app->post('/login/check', function (Request $request, Response $response) use(&$self) {
return $self->responseLoginCheck($request, $response)->withHeader('Content-type', 'application/json')->withHeader('Access-Control-Allow-Origin', '*');
});
$app->options('/login/check', function (Request $request, Response $response, $args) use(&$self) {
return $response->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Access-Control-Allow-Headers', 'Content-Type');
});
}
示例3: register
public function register(App &$app)
{
$app->get('/version', function (Request $request, Response $response) {
$response->getBody()->write(json_encode("v1.0.0"));
return $response->withHeader('Access-Control-Allow-Origin', '*');
});
$app->options('/version', function (Request $request, Response $response, $args) use(&$self) {
return $response->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Access-Control-Allow-Headers', 'Content-Type');
});
}
示例4: testOptionsRoute
public function testOptionsRoute()
{
$path = '/foo';
$callable = function ($req, $res) {
// Do something
};
$app = new App();
$route = $app->options($path, $callable);
$this->assertInstanceOf('\\Slim\\Route', $route);
$this->assertAttributeContains('OPTIONS', 'methods', $route);
}