-
Notifications
You must be signed in to change notification settings - Fork 0
Controllers
Angelo Alejandro Calvo Alfaro edited this page Apr 11, 2018
·
1 revision
An Example of controller with params
package test.controller;
import org.json.JSONObject;
import earlgrey.annotations.CORS;
import earlgrey.annotations.Cache;
import earlgrey.annotations.Controller;
import earlgrey.annotations.ControllerAction;
import earlgrey.annotations.GET;
import earlgrey.annotations.POST;
import earlgrey.annotations.ParamOptional;
import earlgrey.annotations.ParamRequire;
import earlgrey.annotations.Policie;
import earlgrey.annotations.Route;
import earlgrey.core.ControllerCore;
import earlgrey.core.HttpRequest;
import earlgrey.core.HttpResponse;
import test.helpers.Category;
@Controller(description = "Controlador para obtener las actions de auditoria.", name = "Test", version = 1)
@Route(route = "/auditoria")
@CORS
public class Auditoria extends ControllerCore{
//CONTROLADOR DE PRUEBA PARA EFECTUAR DESARROLLO DE LA PLATAFORMA.
@ControllerAction(description = "Acción del controlador utilizada para obtener la metadata de regiones.", name = "auditoria_metadata_regiones", version = 1)
@Route(route = "/regiones/informes")
@Policie(name = "AllPass")
@POST
@Cache(time = 10)
@ParamRequire(name = "category")
public static void regionalstats(HttpRequest req, HttpResponse res){
JSONObject retorno = new JSONObject();
Category cat = new Category(req.getParam("category"));
res.json(cat.toJSON());
return;
}
}