Una introducción a la API de Rails

API significa Programa de interfaz de aplicación, which provides one application to interact with ‘n’ number of applications which is of same/different language, to access the data/functionality.
Creating API application provides more scalability to the web applications. It will also helps for the easy integration with cross domain applications/languages.
• iOS apps
• Android apps
• Node js framework
• Angular js framework

There are 2 ways to achieve this in rails.

1. We can easily create a new API application using gem called rieles-api, que heredan la aplicación de API del controlador de acción en lugar de Base de controlador de acción and it will skip view generation. This will also helps to configure the middlewares.

2. In case the application is already created we have to inherit ActionControllerAPI manually.

Versioning API’s
Once the application is set-up we can create the controller under controller/v1 folder, that will helps for the easy maintenance of versions and releasing new version of API’s. In this controller we can write code for crud or some functionality that can be called by curl or as API request from front end application for the GET, POST, DELETE, PATCH requests gives responses in JSON/xml format, which is in human readable form. This json data can be read and shown from front-end application.

Seguridad
Al pasar el simbólico que se genera para cada usuario y correo electrónico of the user through an api header to secure an api. It can be ensured that there only authenticated user can access and modify data using api. Using these we can authenticate the user and secure the application. According to the data sent and the data matches in the applications we can send the proper responses back to the front-end application.

These are few basic aspects which can be implemented using rails and create a robust API architecture.

Póngase en contacto con nosotros.

Sreedeep Kumar

Desarrollador senior Ruby on Rails 

Suscríbete para recibir las últimas actualizaciones

Artículos Relacionados

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Spanish
English
English
Japanese
German
French
Spanish

envíanos whatsapp

Salir de la versión móvil