Skip to content

Repository files navigation

REST API für REDAXO 5

Eine einfache Möglichkeit eine REST API in REDAXO zu erstellen.

Route registrieren

// https://domain.de/api/my-call
Rest::registerRoute([
'route' => 'my-call',
'methods' => array('POST', 'GET'),
'callback' => 'myCallbackFn',
]);
functionmyCallbackFn($route) {
/** @var RestRoute $route */$data = [
'lorem' => 'ipsum',
'dolor' => [
'sit' => 'amet',
]
];
$route->sendContent($data);
exit;
}
// https://domain.de/api/my-call/12
Rest::registerRoute([
'route' => 'my-call/{articleID}',
'methods' => array('POST', 'GET'),
'callback' => function ($route) {
$articleID = $route->getParam('articleID', 'int');
// ...
},
]);

Full configuration

[
'route' => '/my-call/{articleID}',
'permission' => 'admin', // addon[]'methods' => array('POST', 'GET'),
'validations' => [
'articleID' => 'int', // number, bool/boolean, 
],
'callback' => staticfunction($route) {
/** @var RestRoute $route */$data = [
'lorem' => 'ipsum',
'dolor' => [
'sit' => 'amet',
]
];
$route->sendContent($data);
exit;
},
]

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages