formacao
This commit is contained in:
+9
-4
@@ -118,7 +118,7 @@ var Hono = class _Hono {
|
||||
handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
|
||||
handler[COMPOSED_HANDLER] = r.handler;
|
||||
}
|
||||
subApp.#addRoute(r.method, r.path, handler);
|
||||
subApp.#addRoute(r.method, r.path, handler, r.basePath);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ var Hono = 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);
|
||||
};
|
||||
})();
|
||||
@@ -256,10 +256,15 @@ var Hono = class _Hono {
|
||||
this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
|
||||
return this;
|
||||
}
|
||||
#addRoute(method, path, handler) {
|
||||
#addRoute(method, path, handler, baseRoutePath) {
|
||||
method = method.toUpperCase();
|
||||
path = mergePath(this._basePath, path);
|
||||
const r = { basePath: this._basePath, path, method, handler };
|
||||
const r = {
|
||||
basePath: baseRoutePath !== void 0 ? 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