xp icon indicating copy to clipboard operation
xp copied to clipboard

Support aliases for HTTP methods in controllers

Open alansemenov opened this issue 3 years ago • 1 comments

Problem 1: Handler for delete method in an HTTP controller is currently defined as "exports.delete = function()...". However, developers who are using Javascript module syntax have to define it like this: export function delete.... "delete" is a reserved word in Javascript.

Problem 2: Handler for get method in Javascript module syntax is defined like this: export function get.... If developer in the same module imports get method of, let's say, lib-content like this "import {get} from 'lib/xp/content'" then the http handler get conflicts with the library method get.

Both issues could've been solved if we introduce aliases for HTTP controller methods: http_delete (or httpDelete) for delete, http_get for get etc.

alansemenov avatar Oct 06 '21 08:10 alansemenov

I think httpDelete is a better and more traditional JavaScript naming of functions, instead of http_delete.

tajakobsen avatar Oct 06 '21 11:10 tajakobsen