mardi 19 janvier 2016

Laravel - Adapting existing methods for API

I have a current project made with Laravel and now need to create some API's so a client can communicate with our system. But I'm not sure what the best way to approach this is.

How should I approach something like this the Laravel way? With the functionality already working, I'm not sure if I should validate and adapt their requests somehow so that it fits in with the currently working code, or create another separate function altogether for handling the requests.

For the validation, I'd like to use the FormRequest or extend my own class if needed. And on validation failure, I'd like to be able to return an XML response. I already have the functions for generating the XML, but need a way to return it with the custom error messages defined in the messages() method.

Any direction would be appreciated. Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire