dingo-api

Dingo API - How to add version number in url?

主宰稳场 提交于 2020-05-29 08:45:17
问题 I have just installed Dingo and it appear to work with the following URL: http://website.dev/api/test http://website.dev/api/hello $api = app('Dingo\Api\Routing\Router'); $api->version('v1', function ($api) { $api->get('test', function () { return 'Test'; }); $api->get('hello', function () { return 'Hello'; }); }); I would like version v1 to be included in the URL, how do I get this to work? When I try: http://website.dev/api/v1/test I get error: { "message": "404 Not Found", "status_code":

Dingo API - How to add version number in url?

守給你的承諾、 提交于 2020-05-29 08:44:09
问题 I have just installed Dingo and it appear to work with the following URL: http://website.dev/api/test http://website.dev/api/hello $api = app('Dingo\Api\Routing\Router'); $api->version('v1', function ($api) { $api->get('test', function () { return 'Test'; }); $api->get('hello', function () { return 'Hello'; }); }); I would like version v1 to be included in the URL, how do I get this to work? When I try: http://website.dev/api/v1/test I get error: { "message": "404 Not Found", "status_code":

Dingo API - How to add version number in url?

五迷三道 提交于 2020-05-29 08:43:44
问题 I have just installed Dingo and it appear to work with the following URL: http://website.dev/api/test http://website.dev/api/hello $api = app('Dingo\Api\Routing\Router'); $api->version('v1', function ($api) { $api->get('test', function () { return 'Test'; }); $api->get('hello', function () { return 'Hello'; }); }); I would like version v1 to be included in the URL, how do I get this to work? When I try: http://website.dev/api/v1/test I get error: { "message": "404 Not Found", "status_code":

Laravel 5.4 - Cookie Queue

爷,独闯天下 提交于 2020-05-26 04:32:37
问题 I'm using Laravel 5.4 and I wrote something like: Cookie::queue( 'refresh_token', $data->refresh_token, 864000, // 10 days null, null, false, true // HttpOnly ); return response('hello world'); The returned response doesn't contain the refresh_token cookie while return response('hello world')->withCookie(...) does. The Laravel 5.4 documentation doesn't anymore state queueing cookie as 5.0 doc does. Does it mean that the functionality has been removed in version 5.4 or did I make a mistake in

No query results for model in Laravel with Dingo - how to make a RESTful response on failure?

左心房为你撑大大i 提交于 2020-01-29 20:48:26
问题 I'm creating an API with Laravel based on the Dingo API. In my routes, I have: Route::api('v1', function () { Route::resource('object', 'My\Namespace\MyController'); }); And in MyController: class MyController extends \Illuminate\Routing\Controller { use Dingo\Api\Routing\ControllerTrait; public function index() { return MyObject::all(); } public function show($id) { return MyObject::findOrFail($id); } } This means that api.domain.com/object calls MyController@index , which works. Since there

Lumen + Dingo + JWT is not instantiable while building

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 12:11:03
问题 I am trying to get a basic working foundation for a Lumen + Dingo Rest API, but I am not able to figure out how to peace is all together. Lumen is working fine, but when I try to add Dingo I get all sorts of errors. From the Dingo documentation I read: Once you have the package you can configure the provider in your config/api.php file or in a service provider or bootstrap file. 'jwt' => 'Dingo\Api\Auth\Provider\JWT' or app('Dingo\Api\Auth\Auth')->extend('jwt', function ($app) { return new

Laravel : Dingo/API Pagination custom root key

别等时光非礼了梦想. 提交于 2019-12-12 01:43:50
问题 I've developed an API with Laravel 5 and Dingo/API. Following the documentation, i used pagination and my code look like that $users = User::paginate(50); return $this->response->paginator($users, new UserTransformer); Unfortunately, the response root key is "data" { "data": [ { "id": 1, "username": "superuser", ...... I'd like to change the "data" key to a custom one, because in my case, emberjs get this response and try to make a link with a "datum" model which doesn't exist, the key need

Dingo API remove “data” envelope

…衆ロ難τιáo~ 提交于 2019-12-05 15:08:45
问题 is it there an easy way to remove the "data" envelope from the Dingo API response. When I use this Transformer to transform user models: class UserTransformer extends EloquentModelTransformer { /** * List of resources possible to include * * @var array */ protected $availableIncludes = [ 'roles' ]; protected $defaultIncludes = [ 'roles' ]; public function transform($model) { if(! $model instanceof User) throw new InvalidArgumentException($model); return [ 'id' => $model->id, 'name' => $model-

No query results for model in Laravel with Dingo - how to make a RESTful response on failure?

一笑奈何 提交于 2019-12-01 11:06:36
I'm creating an API with Laravel based on the Dingo API . In my routes, I have: Route::api('v1', function () { Route::resource('object', 'My\Namespace\MyController'); }); And in MyController: class MyController extends \Illuminate\Routing\Controller { use Dingo\Api\Routing\ControllerTrait; public function index() { return MyObject::all(); } public function show($id) { return MyObject::findOrFail($id); } } This means that api.domain.com/object calls MyController@index , which works. Since there are no items in the database, this then outputs an empty json array [] . api.domain.com/object/123