veeque
veeque
Explore posts from servers
HHono
Created by veeque on 9/11/2024 in #help
How do I get rest params?
Take the following app:
import { Hono } from "hono";
import { trimTrailingSlash } from "hono/trailing-slash";

const app = new Hono();

app.use(trimTrailingSlash());

app.get("/", async (c) => {
return c.text("This is the Cloudflare page for /");
});

app.get("/app/:app/*", async (ctx) => {
return ctx.text(
`You have requested the ${ctx.req.param(
"app"
)} application on the "${ctx.req.param("*")}" path`
);
});

export default app;
import { Hono } from "hono";
import { trimTrailingSlash } from "hono/trailing-slash";

const app = new Hono();

app.use(trimTrailingSlash());

app.get("/", async (c) => {
return c.text("This is the Cloudflare page for /");
});

app.get("/app/:app/*", async (ctx) => {
return ctx.text(
`You have requested the ${ctx.req.param(
"app"
)} application on the "${ctx.req.param("*")}" path`
);
});

export default app;
It would be nice if this worked, but doing ctx.req.param("*") doesn't give you the remaining params. I need this as I have to forward those to a separate Cloudflare pages application.
2 replies