'Entry point for the REST API
@param r: the S3Request
@param attr: controller parameters'

def apply_method(self, r, **attr):

    output = {}
    representation = r.representation
    if (representation == 'html'):
        if (r.http == 'GET'):
            output = self.check_in_form(r, **attr)
        else:
            r.error(405, current.ERROR.BAD_METHOD)
    elif (representation == 'json'):
        if (r.http == 'POST'):
            output = self.submit_ajax(r, **attr)
        else:
            r.error(405, current.ERROR.BAD_METHOD)
    else:
        r.error(415, current.ERROR.BAD_FORMAT)
    return output
