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

Minimal HTTP router in JSX #3

Merged
merged 5 commits into from
Apr 2, 2024
Merged

Minimal HTTP router in JSX #3

merged 5 commits into from
Apr 2, 2024

Conversation

EthanThatOneKid
Copy link
Collaborator

@EthanThatOneKid EthanThatOneKid commented Apr 1, 2024

Changes

  • Exports a module containing jsonx components for composing rtx routers.

Example

if (import.meta.main) {
const router = (
<Router>
<Get
pattern="/favicon.ico"
handle={() =>
new Response(null, {
status: 302,
headers: { Location: "https://deno.com/favicon.ico" },
})}
/>
<Get pattern="/" handle={() => new Response("Hello, World!")} />
<Get pattern="/foo" handle={() => new Response("foo")} />
<Get pattern="/bar" handle={() => new Response("bar")} />
<Get pattern="/baz" handle={() => new Response("baz")} />
</Router>
);
Deno.serve((request) => router.fetch(request));
}

Copy link
Collaborator Author

@EthanThatOneKid EthanThatOneKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be useful to create a separate repository for components related to jsonx, as most rtx users are unlikely to use them for rtx router implementation.

Copy link
Collaborator Author

@EthanThatOneKid EthanThatOneKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing capability to set default fallback handler in router definition.

@EthanThatOneKid
Copy link
Collaborator Author

It may be useful to create a separate repository for components related to jsonx, as most rtx users are unlikely to use them for rtx router implementation.

Separating jsonx components into a dedicated repository makes sense. Most users likely wouldn't interact with them for core router functionality.

To achieve this separation, we'll be making some changes:

  • Core implementation will move to a new repository named rt.
  • The rtx repository will focus on exporting jsonx components for rt. This initial implementation using the x suffix establishes a new naming convention for jsonx components.

@EthanThatOneKid EthanThatOneKid merged commit 71a4259 into main Apr 2, 2024
1 check passed
@EthanThatOneKid EthanThatOneKid deleted the components branch April 2, 2024 06:37
EthanThatOneKid added a commit to FartLabs/.github that referenced this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant