 # It supports strictly methods defined in the HTTP specification.
 module.exports.Api = class Api extends service.Service
 
+    # This method is intended for indicating to a client that the
+    # method that has been used to make the request is not supported
+    # by this service of the internals that are comprising service.
+    # Can be used from the outside, but generally should not be done.
+    unsupported: (request, response, next) ->
+        methodNotAllowed = 405
+        codes = http.STATUS_CODES
+        message = codes[methodNotAllowed]
+        accept = request?.headers?.accept or ""
+        handles = (mime) -> accept.indexOf(mime) >= 0
+        response.statusCode methodNotAllowed
+        response.end(error: message) if handles("json")
+        response.end(message); this
+
     # Process the already macted HTTP request according to the REST
     # specification. That is, see if the request method conforms to
     # to the RFC, and if so, dispatch it onto corresponding method

        tokens = super(request, response, next)
        parameters = [request, response, next]
        knowns = ["GET", "PUT", "POST", "DELETE", "OPTIONS"]
        method = request.method?.toUpperCase()?.trim()
        return @unsupported(parameters...) unless method in knowns
        missing = "Missing implementation for #{method} method"
        throw new Error(missing) unless method of this
        variables = [tokens.resource, tokens.domain]
        this[method](request, response, variables...); this

    # This method is intended for indicating to a client that the
    # method that has been used to make the request is not supported
    # by this service of the internals that are comprising service.
    # Can be used from the outside, but generally should not be done.
    unsupported: (request, response, next) ->
        methodNotAllowed = 405
        codes = http.STATUS_CODES
        message = codes[methodNotAllowed]
        accept = request.headers.accept or ""
        handles = (mime) -> accept.indexOf(mime) >= 0
        response.statusCode methodNotAllowed
        response.end(error: message) if handles("json")
        response.end(message); this

    # Get the contents of the resources at the established path. It
    # is a good idea for this HTTP method to be idempotent. As the
    # rule, this method does not have to alter any contents or data
    # of the resource. Use for unobtrusive retrieval of resources.
    GET: @::unsupported

    # Alter the contents of the resources at the established path. It
    # usually means replacing the old contents with the new contents.

    # Use this method to repetidely replace the contents of resources.
    PUT: @::unsupported

    # Get the contents of the resources at the established path. It
    # is a good idea for this HTTP method to be idempotent. As the
    # rule, this method does not have to alter any contents or data
    # of the resource. Use for unobtrusive retrieval of resources.
    GET: @::unsupported
