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'); }); }
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'); }); }
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'); }); }
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); }