Reputation: 12867
What's the recommended / supposed way to use a custom base path for Restler when it's not deployed at the root of a domain / subdomain?
My site has its own routing and I'm using Restler 3.0 at here:
http://www.example.com/api/data/movies
When it routes to /api/data/movies
, I'm letting Restler take charge:
class Say {
function hello($to='world') {
return "Hello $to!";
}
function hi($to) {
return "Hi $to!";
}
}
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Say', '/api/data/movies/say');
$r->handle();
However, somehow it's not getting the parameters passed to it via sub-path. See below.
{
"error": {
"code": 400,
"message": "Bad Request: `to` is required."
},
"debug": {
"source": "Validator.php:366 at validate stage",
"stages": {
"success": [
"get",
"route",
"negotiate"
],
"failure": [
"validate",
"message"
]
}
}
}
{
"error": {
"code": 404,
"message": "Not Found"
},
"debug": {
"source": "Routes.php:431 at route stage",
"stages": {
"success": [
"get"
],
"failure": [
"route",
"negotiate",
"message"
]
}
}
}
I tried to Google but found nothing relevant to my problem. How can I make it work? What's the recommended / supposed way to use Restler under a sub-directory-URL instead of a domain / sub-domain root?
Upvotes: 0
Views: 452
Reputation: 993
With auto routing required primitive types used to be mapped to url path, this behaviour changed in the recent releases. Sorry about the confusion, we updated the documentation now!
Upvotes: 1
Reputation: 3195
As per Restler Documentation
You must have to pass to
parameter in your URL Request, So I think your URL should be example.com/api/data/movies/say/hi?to=test
.
But If you want to add custom Routing then Check how Restler Routing Works.
This API Server exposes the following URIs
GET say/hi/{to} ⇠ Say::hi()
I am not familiar with Restler, But I hope this should be help for you.
Upvotes: 1