Repository navigation
Convert SSR example to dynamic HTTP-served first paint - #22
Merged
Merged
Conversation
The SSR example previously served a static index.html with hardcoded pre-rendered content, requiring a separate python HTTP server. Now that mare 0.2.0 and hobby 0.2.1 share a compatible lori version, the example uses hobby to serve the initial page dynamically. A hobby HTTP server on port 8085 handles GET / by calling PageRenderer.render(factory) to produce the counter HTML at request time, embedding it in a full page shell with the JS client script tag. It also serves the JS client bundle via ServeFiles on /client/*. The WebSocket server on port 8084 continues handling live updates. The factory is shared between both servers so the pre-rendered and live views always match. Closes #19
hobby's respond_with_headers doesn't auto-set Content-Length (unlike respond), so the caller must include it. Without it, HTTP/1.1 clients rely on connection-close to detect end-of-body, breaking keep-alive. Filed ponylang/hobby#36 to address this at the framework level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the static index.html in the SSR example with a hobby HTTP server that dynamically renders the initial page using PageRenderer.
A hobby HTTP server on port 8085 handles two routes: GET / calls PageRenderer.render(factory) to produce the counter's HTML at request time and serves it in a full page shell, and GET /client/* serves the JS client bundle via ServeFiles. The WebSocket server on port 8084 continues handling live updates. The factory is shared between both servers so the pre-rendered and live views always match.
The SSR example no longer needs a separate python HTTP server — just run the binary and visit http://localhost:8085/.
Closes #19