Skip to content

Commit

Permalink
🚧 wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Jul 17, 2019
1 parent 74ce500 commit 303c508
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 10 additions & 4 deletions Chevereto-Chevere/src/Api.php
Expand Up @@ -105,13 +105,19 @@ public function register(string $pathIdentifier)
$this->processRoutesMap();

$this->uri = '/'.$this->basePath;

$httpMethods = [
'HEAD' => Controllers\ApiHead::class,
'OPTIONS' => Controllers\ApiOptions::class,
'GET' => Controllers\ApiGet::class,
];
$apiEndpoint = new ApiEndpoint($httpMethods);

$this->route = Route::bind($this->uri)
->setMethod('HEAD', Controllers\ApiHead::class)
->setMethod('OPTIONS', Controllers\ApiOptions::class)
->setMethod('GET', Controllers\ApiGet::class)
->setMethods($httpMethods)
->setId($this->basePath);
$this->getRouter()->addRoute($this->route, $this->basePath);
$this->apis[$this->basePath] = $this->api;
$this->apis[$this->basePath] = $apiEndpoint->toArray();
}

protected function handleEmptyRecursiveIterator(): void
Expand Down
3 changes: 1 addition & 2 deletions Chevereto-Chevere/src/Controllers/ApiOptions.php
Expand Up @@ -64,9 +64,8 @@ private function process()
{
$statusCode = 200;
$api = $this->getApi();
dd($api);
$endpoint = $api->getEndpoint($this->endpoint);
if ($endpoint) {
if ($endpoint['OPTIONS']) {
$this->getResponse()->addData('OPTIONS', $this->uri, $endpoint['OPTIONS']);
} else {
$statusCode = 404;
Expand Down

0 comments on commit 303c508

Please sign in to comment.