...
Codeblock | ||
---|---|---|
| ||
import { RouterBuilder } from '@de.pinuts.apirouter/shared/routing.es6'; class DocumentController { list() { // Will be called when requesting GET <http://localhost:8080/cmsbs/rest/de.mycompany.restdemo.api/document> } show() { // Will be called when requesting GET <http://localhost:8080/cmsbs/rest/de.mycompany.restdemo.api/document/123> UM.dump(params, 'params:'); } update() { // Will be called when requesting PUT <http://localhost:8080/cmsbs/rest/de.mycompany.restdemo.api/document/123> UM.dump(params, 'params:'); } create() { // Will be called when requesting POST <http://localhost:8080/cmsbs/rest/de.mycompany.restdemo.api/document> UM.dump(params, 'params:'); } delete() { // Will be called when requesting DELETE <http://localhost:8080/cmsbs/rest/de.mycompany.restdemo.api/document/123> UM.dump(params, 'params:'); } beforeInterceptor() { // Add your custom authorization code here. return true; } } const routerBuilder = new RouterBuilder() .protectFromForgery() .protectFromCaching() .allowCors() .handlePreflightRequests() .get('/document/:id', DocumentController, 'listshow') .get('/document/:id', DocumentController, 'showlist') .put('/document/:id', DocumentController, 'update') .post('/document', DocumentController, 'create') .delete('/document/:id', DocumentController, 'delete'); de.mycompany.restdemo.apiController = routerBuilder.build(); |
...