Permalink
Browse files

Merge pull request #82 from shades3002/master

preflight requests response
  • Loading branch information...
2 parents 584aa06 + 867b26e commit b66b6336f2b2463b93a5acc35a4bb0dc6a5e8a5f @jacwright committed on GitHub Apr 3, 2017
Showing with 9 additions and 0 deletions.
  1. +9 −0 source/Jacwright/RestServer/RestServer.php
@@ -103,6 +103,10 @@ public function unauthorized($ask = false)
throw new RestException(401, "You are not authorized to access this resource.");
}
+ public function options()
+ {
+ throw new RestException(200, "authorized");
+ }
public function handle()
{
@@ -114,6 +118,11 @@ public function handle()
$this->data = $this->getData();
}
+ //preflight requests response
+ if($this->method == 'OPTIONS' && getallheaders()['Access-Control-Request-Headers']){
+ $this->sendData($this->options());
+ }
+
list($obj, $method, $params, $this->params, $noAuth) = $this->findUrl();
if ($obj) {

0 comments on commit b66b633

Please sign in to comment.