@halsp/http
Version:
支持 Halsp HTTP 请求
50 lines • 1.49 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpMethods = void 0;
class HttpMethods {
static any = "ANY";
static get = "GET";
static post = "POST";
static put = "PUT";
static delete = "DELETE";
static patch = "PATCH";
static head = "HEAD";
static options = "OPTIONS";
static trace = "TRACE";
static connect = "CONNECT";
static move = "MOVE";
static copy = "COPY";
static link = "LINK";
static unlink = "UNLINK";
static wrapped = "WRAPPED";
static matched(method, customMethods = []) {
if (!method)
return undefined;
switch (method.toUpperCase()) {
case this.any:
case this.get:
case this.post:
case this.put:
case this.delete:
case this.patch:
case this.head:
case this.options:
case this.trace:
case this.connect:
case this.move:
case this.copy:
case this.link:
case this.unlink:
case this.wrapped:
return method.toUpperCase();
default: {
return customMethods.filter((item) => this.equal(item, method))[0];
}
}
}
static equal(method1, method2) {
return (method1 ?? "").toUpperCase() == (method2 ?? "").toUpperCase();
}
}
exports.HttpMethods = HttpMethods;
//# sourceMappingURL=methods.js.map
;