Skip to content

Commit

Permalink
Updates to improvements on keeko/framework
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed Jul 20, 2016
1 parent be513a8 commit 245f9e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/ApiApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ class ApiApplication extends AbstractApplication {

public function run(Request $request) {
$response = new JsonResponse();
$this->router = new ApiRouter($request, ['basepath' => $this->getAppPath()]);
$path = str_replace('//', '/', '/' . $this->getDestinationPath());
$this->router = new ApiRouter($request, ['basepath' => $this->uri->getBasepath()]);

try {
$match = $this->router->match($path);
$match = $this->router->match($this->getDestination());

// set headers for CORS
if ($request->isMethod('options')) {
Expand Down Expand Up @@ -66,7 +65,7 @@ public function run(Request $request) {
$response->setData($this->exceptionToJson($e));
}

$response = $this->setCorsHeaders($response, $path);
$response = $this->setCorsHeaders($response, $this->getDestination());

return $this->postProcessing($response);
}
Expand Down
3 changes: 2 additions & 1 deletion src/ApiRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public function __construct(Request $request, array $options) {
);

// debug: print routes
// printf('%s: %s -> %s<br>', $api->getMethod(), $path, $module->getName() . ':' . $action->getName());
// printf("%s: %s -> %s\n", $api->getMethod(), $path, $module->getName() . ':' . $action->getName());

$routes->add($name, $route);

// with params
$paramRoute = clone $route;
$paramRoute->setPath(sprintf('%s%s{params}', $path, $this->options['param-separator']));
$paramRoute->setRequirement('params', '.+');
$paramName = $name . 'WithParam';

$routes->add($paramName, $paramRoute);
Expand Down

0 comments on commit 245f9e6

Please sign in to comment.