formacao
This commit is contained in:
+9
-5
@@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
@@ -140,7 +139,7 @@ class Hono {
|
||||
handler = async (c, next) => (await (0, import_compose.compose)([], app.errorHandler)(c, () => r.handler(c, next))).res;
|
||||
handler[import_constants.COMPOSED_HANDLER] = r.handler;
|
||||
}
|
||||
subApp.#addRoute(r.method, r.path, handler);
|
||||
subApp.#addRoute(r.method, r.path, handler, r.basePath);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
@@ -264,7 +263,7 @@ class Hono {
|
||||
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
||||
return (request) => {
|
||||
const url = new URL(request.url);
|
||||
url.pathname = url.pathname.slice(pathPrefixLength) || "/";
|
||||
url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
|
||||
return new Request(url, request);
|
||||
};
|
||||
})();
|
||||
@@ -278,10 +277,15 @@ class Hono {
|
||||
this.#addRoute(import_router.METHOD_NAME_ALL, (0, import_url.mergePath)(path, "*"), handler);
|
||||
return this;
|
||||
}
|
||||
#addRoute(method, path, handler) {
|
||||
#addRoute(method, path, handler, baseRoutePath) {
|
||||
method = method.toUpperCase();
|
||||
path = (0, import_url.mergePath)(this._basePath, path);
|
||||
const r = { basePath: this._basePath, path, method, handler };
|
||||
const r = {
|
||||
basePath: baseRoutePath !== void 0 ? (0, import_url.mergePath)(this._basePath, baseRoutePath) : this._basePath,
|
||||
path,
|
||||
method,
|
||||
handler
|
||||
};
|
||||
this.router.add(method, path, [handler, r]);
|
||||
this.routes.push(r);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user