Skip to content

Commit

Permalink
Support issue id as part of the path
Browse files Browse the repository at this point in the history
Support paths like:
https://…./api/rest/issues/12345

In addition to:
https://…./api/rest/issues?id=12345
  • Loading branch information
vboctor committed Aug 5, 2017
1 parent 32fd4fb commit ca19157
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/rest/restcore/issues_rest.php
Expand Up @@ -25,10 +25,14 @@
$g_app->group('/issues', function() use ( $g_app ) {
$g_app->get( '', 'rest_issue_get' );
$g_app->get( '/', 'rest_issue_get' );
$g_app->get( '/{id}', 'rest_issue_get' );
$g_app->get( '/{id}/', 'rest_issue_get' );
$g_app->post( '', 'rest_issue_add' );
$g_app->post( '/', 'rest_issue_add' );
$g_app->delete( '', 'rest_issue_delete' );
$g_app->delete( '/', 'rest_issue_delete' );
$g_app->delete( '/{id}', 'rest_issue_delete' );
$g_app->delete( '/{id}/', 'rest_issue_delete' );
});

/**
Expand All @@ -40,7 +44,7 @@
* @return \Slim\Http\Response The augmented response.
*/
function rest_issue_get( \Slim\Http\Request $p_request, \Slim\Http\Response $p_response, array $p_args ) {
$t_issue_id = $p_request->getParam( 'id' );
$t_issue_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' );

if( !is_blank( $t_issue_id ) ) {
# Get Issue By Id
Expand Down Expand Up @@ -115,7 +119,7 @@ function rest_issue_add( \Slim\Http\Request $p_request, \Slim\Http\Response $p_r
* @return \Slim\Http\Response The augmented response.
*/
function rest_issue_delete( \Slim\Http\Request $p_request, \Slim\Http\Response $p_response, array $p_args ) {
$t_issue_id = $p_request->getParam( 'id' );
$t_issue_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' );

# Username and password below are ignored, since middleware already done the auth.
$t_result = mc_issue_delete( /* username */ '', /* password */ '', $t_issue_id );
Expand Down

1 comment on commit ca19157

@dregad
Copy link
Member

@dregad dregad commented on ca19157 Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elmarculino the github repository is not a private messaging system. You opened an issue, that's great, this is where the discussion should take place. You can @mention people there as well. Please leave comments in the github repository focused on issues related to the code. Thanks for your understanding.

Please sign in to comment.