Reputation: 3
how do i access the rest service http://www.example.com/zf2/services/call/login which is getting an error "error-router-no-match"
My Module.config
return array(
'router' => array(
'routes' => array(
'services' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/services',
'defaults' => array(
'__NAMESPACE__' => 'Restapi\Controller\restapi',
),
),
),
'services' => array(
'type' => 'segment',
'may_terminate' => true,
'options' => array(
'route' => '/services[/:id]',
'constraints' => array(
'id'=>'[0-9a-zA-Z]+',
),
'defaults' => array(
'controller' => 'Restapi\Controller\rest',
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Restapi\Controller\Rest' => 'Restapi\Controller\RestapiController',
),
),
'view_manager' => array(
'strategies' => array(
'ViewJsonStrategy`'`,
),
),
);
Upvotes: 0
Views: 66
Reputation: 11
As I see you have invalid route setup. At first: one services section rewrites another. You can just set default values, so first section services is unnecessary. Second section doesn't have appropriate route - it can handle only requests like
To accept services/call/login route have to be something like this
<?php
return array(
'router' => array(
'routes' => array(
'services' => array(
'type' => 'segment',
'may_terminate' => true,
'options' => array(
'route' => '/services[/[:controller[/:action]]]',
'constraints' => array('id' => '[0-9a-zA-Z]+',),
'defaults' => array(
'controller' => 'Restapi\Controller\rest',
'action' => 'index', // Default action for "/services" route
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Restapi\Controller\Rest' => 'Restapi\Controller\RestapiController',
),
),
'view_manager' => array(
'strategies' => array(
'ViewJsonStrategy',
),
),
);
Upvotes: 1