Docs‎ > ‎CA Live API Creator‎ > ‎Create‎ > ‎

Custom Endpoints

You can define your own RESTful end points, as an Custom Endpoints.  These handlers are free form and do not need to map to a specific data model.  The JavaScript can implement any functionality and return a JSON response.

Copy the contents of the URL to a new browser page.

Your handler will have access to the request object, and can specify response headers, as in this example:

responseHeaders.put('Content-Type', 'application/x-acme-special-json');
return JSON.stringify({
    result: 'Hello',
    uri: "" + request.getRequestURI(),  // Partial path without host/port
    url: "" + request.getRequestURL(),  // Full URL
    method: "" + request.getMethod(),  // GET, POST, etc
    pathInfo: "" + request.getPathInfo(),  //  /<account>/<project>/<path>
    acceptHeader: "" + request.getHeader("Accept"),  // Any HTTP header
    fooParam: "" + request.getParameter("foo")   // Gets value of e.g. ...?foo=123

Please note that the request object is a Java request object (more specifically an instance of HttpServletRequest), which is different than the request objects you get in other contexts (rules, events, etc...). This is because, when writing a handler, you are completely taking control -- Live API Creator will therefore not create a standard request object.

Similarly, the responseHeaders variable is a Java Map. You can call get and put on it. If you do not specify any response headers, application/json is returned by default.