Support multiple method types for REST http endpoints

whilst working on this ticket cfcontent with a file url which returns a 403 doesn’t throw an exception / fileExists returns true

I found a bit of an edge case, REST endpoints only support a single http method (at least in Lucee), but with Lucee when you access a http resource (or any other for that matter) does an exists check first, which is a HEAD request in this case, which fails

fileRead("http://update.lucee.org/rest/update/provider/echoGet") throws an error on the HEAD exists check

remote function echoGET(
                string statusCode="" restargsource="url",
                string mimeType="" restargsource="url",
                string charset="" restargsource="url")
            httpmethod="GET"
            restpath="echoGet" {
        return _echo(arguments.statusCode, arguments.mimeType, arguments.charset);
    }

solution would be to support

remote function echoGET(
                string statusCode="" restargsource="url",
                string mimeType="" restargsource="url",
                string charset="" restargsource="url")
            httpmethod="GET,HEAD"
            restpath="echoGet" {
        return _echo(arguments.statusCode, arguments.mimeType, arguments.charset);
    }

ACF docs cffunction
<cffunction> :: Lucee Documentation (undocumented…as not an argument)
REST Services: Introduction :: Lucee Documentation

thoughts, feelings?

2 Likes

OPTIONS is another http method I have to add along in my code.