MCPcopy
hub / github.com/fastify/fastify / addHttpMethod

Function addHttpMethod

fastify.js:828–849  ·  fastify.js::addHttpMethod
(method, { hasBody = false } = {})

Source from the content-addressed store, hash-verified

826 }
827
828 function addHttpMethod (method, { hasBody = false } = {}) {
829 if (typeof method !== class="st">'string' || http.METHODS.indexOf(method) === -1) {
830 throw new FST_ERR_ROUTE_METHOD_INVALID()
831 }
832
833 if (hasBody === true) {
834 this[kSupportedHTTPMethods].bodywith.add(method)
835 this[kSupportedHTTPMethods].bodyless.delete(method)
836 } else {
837 this[kSupportedHTTPMethods].bodywith.delete(method)
838 this[kSupportedHTTPMethods].bodyless.add(method)
839 }
840
841 const _method = method.toLowerCase()
842 if (!this.hasDecorator(_method)) {
843 this.decorate(_method, function (url, options, handler) {
844 return router.prepareRoute.call(this, { method, url, options, handler })
845 })
846 }
847
848 return this
849 }
850}
851
852function processOptions (options, defaultRoute, onBadUrl, onMaxParamLength) {

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
hasDecoratorMethod · 0.80

Tested by

no test coverage detected