Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Custom Services

Tobe O edited this page Jan 31, 2017 · 8 revisions

Custom Services

Assuming you have already read Service Basics, the process of implementing your own service is very straightforward. Simply implement the methods you want to expose.

By default, a service will throw a 405 Method Not Allowed error if you haven't written any logic to handle a given method. This means you only need to write handlers for operations you plan to actually have carried out.

Do make sure to invoke the super constructor in any of your constructors, as that's where services set up their routes. Without it, your service will not be accessible to the Internet, as it will not have any front-facing routes set up at all.

class MyService extends Service {
  MyService():super() {
    // Feel free to add your own constructor, just don't
    // neglect the `super`...
  }
}

Note: The convention for the remove method on services is that if id == null, all entries in the store should be removed. Obviously, this does not work very well in production, so only allow this to occur on the server side. Common service providers will disable this for clients, unless you explicitly set a flag dictating so.

Clone this wiki locally