Skip to content

update docs with an example showing use with Revise.jl #587

@clarkevans

Description

@clarkevans

Web developers need a way to automatically update server behavior with changes to local development files. This is unobvious for those unfamiliar with HTTP.jl, Revise.jl, and their interaction. Below is a proposed example that works, at least for local development.

# hello.jl -- an example showing how Revise.jl works with HTTP.jl
# julia> using Revise; includet("hello.jl"); serve();

using HTTP
using Sockets

homepage(req::HTTP.Request) =
    HTTP.Response(200, "<html><body>Hello World!</body></html>")

const ROUTER = HTTP.Router()
HTTP.@register(ROUTER, "GET", "/", homepage)

serve() = HTTP.listen(request -> begin
                 Revise.revise()
                 Base.invokelatest(HTTP.handle, ROUTER, request)
          end, Sockets.localhost, 8080, verbose=true)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions