Skip to content

Commit

Permalink
Merge pull request #271 from JuliaGizmos/sd-fix_http
Browse files Browse the repository at this point in the history
fix webserver for HTTP 0.8 + WebSockets 1.5
  • Loading branch information
SimonDanisch authored Apr 15, 2019
2 parents a13b0fa + 198d5e7 commit 8e4ba94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/providers/generic_http.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,20 @@ function WebIOServer(
baseurl::String = "127.0.0.1", http_port::Int = 8081,
verbose = false, singleton = true,
websocket_route = "/webio_websocket/",
logger = devnull,
server_kw_args...
)
# TODO test if actually still running, otherwise restart even if singleton
if !singleton || !isassigned(singleton_instance)
handler = HTTP.HandlerFunction() do req
function handler(req)
response = default_response(req)
response !== missing && return response
return serve_assets(req)
end
wshandler = WebSockets.WebsocketHandler() do req, sock
function wshandler(req, sock)
req.target == websocket_route && websocket_handler(sock)
end
server = WebSockets.ServerWS(handler, wshandler, logger; server_kw_args...)
server_task = with_logger(NullLogger()) do
@async WebSockets.serve(server, baseurl, http_port, verbose)
end
server = WebSockets.ServerWS(handler, wshandler; server_kw_args...)
server_task = @async WebSockets.serve(server, baseurl, http_port, verbose)
singleton_instance[] = WebIOServer(server, server_task)
end
return singleton_instance[]
Expand Down
4 changes: 0 additions & 4 deletions test/http-tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ using WebIO
using WebSockets
using Test

# Don't test until HTTP.jl version issues are fixed.
if false
@testset "HTTP provider" begin
output = sprint(io-> show(io, WebIO.WEBIO_APPLICATION_MIME(), node(:div, "hello, world")))
@test occursin("_webIOWebSocketURL = ", output)
Expand All @@ -12,5 +10,3 @@ if false
@test WebIO.webio_server_config[] == (url = "127.0.0.1", bundle_url = WebIO.bundle_key, http_port = 8081, ws_url = "ws://127.0.0.1:8081/webio_websocket/")
@test isassigned(WebIO.singleton_instance)
end
end

0 comments on commit 8e4ba94

Please sign in to comment.