docs(server): developing generated server handlers with Revise - #133
Merged
Merged
Conversation
…t middleware HTTP.jl 2.x no longer calls handlers through Base.invokelatest, so a running generated server keeps the method world it started in and does not see handler edits made with Revise. Document wrapping handlers with Base.invokelatest through register!'s middleware keyword, why it is not the default (it cannot be compiled with --trim), and add a test that a redefined handler is picked up without restarting the server. Closes #118
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.
Closes #118.
HTTP.jl 2.x no longer calls handlers through
Base.invokelatest. A running generated server therefore keeps the method world it started in, and doesn't see handler edits made with Revise.docs/src/servers.md, with a pointer from the README. It shows how to wrap handlers withBase.invokelatestthroughregister!'smiddlewarekeyword. It also explains why this isn't the default:invokelatestcannot be compiled with--trim.test/servergen.jlchecks that a handler redefined while the server is running is picked up without a restart.Full suites pass on Julia 1.12 and 1.10. The reviewer reproduced the stale-handler behaviour outside the test: without the middleware, the server returns the old result; with it, the new one.
Possible follow-up (minor review note)
Add a negative control to the test: a server started without the middleware should keep returning the old result. That would pin down the premise the docs describe.