MCPcopy Create free account
hub / github.com/fastify/fastify / addHttpMethod

Function addHttpMethod

fastify.js:821–842  ·  view source on GitHub ↗
(method, { hasBody = false } = {})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
hasDecoratorMethod · 0.80

Tested by

no test coverage detected