Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always add default GET handler #2530

Closed
marvinhagemeister opened this issue Jun 23, 2024 · 2 comments · Fixed by #2542
Closed

Always add default GET handler #2530

marvinhagemeister opened this issue Jun 23, 2024 · 2 comments · Fixed by #2542
Labels
bug Something isn't working.
Milestone

Comments

@marvinhagemeister
Copy link
Collaborator

From discord: https://discord.com/channels/684898665143206084/991511118524715139/1254411831041196133

I've just been reading through some of the decisions made for Fresh 2.0. There's a lot of progress, so great work! I have one question regarding the use of the new define helpers. If a route only needs a POST handler, will we still need to define a GET handler? I did like just exporting a default page component for basic pages and then defining a POST handler. It seems (maybe I'm wrong) in the early alpha I need to define a default GET handler too (one that just returns the page) if I define a POST handler.

We should definitely add a default handler. Was an oversight on my part, there is no reason for it to not be there.

@marvinhagemeister marvinhagemeister added the bug Something isn't working. label Jun 23, 2024
@marvinhagemeister marvinhagemeister added this to the Fresh 2 milestone Jun 23, 2024
@deer
Copy link
Contributor

deer commented Jun 23, 2024

Just confirming I understand the request here. Imagine I have a route like this:

import { define } from "../utils.ts";

export const handler = define.handlers({
  POST: (_ctx) => {
    console.log("i've posted");
    return new Response("POST");
  },
});

export default define.page(function PostPage() {
  return <b>"This is a basic page."</b>;
});

What we want is for visiting http://localhost:8000/post with the browser to return This is a basic page. instead of Method Not Allowed, right?

@marvinhagemeister
Copy link
Collaborator Author

Yup, that should be the outcome. It should also work when no define.* handler is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
2 participants