Skip to content

Commit e8344fb

Browse files
authored
Merge pull request #185 from plotly/dev
Release 1.2.0
2 parents 965ac54 + 6804220 commit e8344fb

17 files changed

+174
-145
lines changed

.circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ workflows:
5757
build:
5858
jobs:
5959
- "test"
60+
when: false # disable this workflow until Percy tests are functional again

.github/workflows/jl_test.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Run Julia tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
jl_version: ["1.6", "1.8"]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: julia-actions/setup-julia@v1
15+
with:
16+
version: ${{ matrix.jl_version }}
17+
- uses: julia-actions/julia-buildpkg@v1
18+
- uses: julia-actions/julia-runtest@v1
19+
with:
20+
annotate: true

CompatHelper.yml

-26
This file was deleted.

Project.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Dash"
22
uuid = "1b08a953-4be3-4667-9a23-3db579824955"
33
authors = ["Chris Parmer <[email protected]>", "Alexandr Romanenko <[email protected]>"]
4-
version = "1.1.2"
4+
version = "1.2.0"
55

66
[deps]
77
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -30,14 +30,14 @@ DashCoreComponents = "2.0.0"
3030
DashHtmlComponents = "2.0.0"
3131
DashTable = "5.0.0"
3232
DataStructures = "0.17, 0.18"
33-
HTTP = "0.8.10, 0.9"
33+
HTTP = "1"
3434
JSON = "0.21"
3535
JSON3 = "1.9"
3636
MD5 = "0.2"
3737
PlotlyBase = "0.8.5, 0.8.6"
38-
YAML = "0.4.7"
39-
julia = "1.3"
4038
Requires = "1.3"
39+
YAML = "0.4.7"
40+
julia = "1.6"
4141

4242
[extras]
4343
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Dash for Julia
22

3+
[![Juila tests](https://github.com/plotly/Dash.jl/actions/workflows/jl_test.yml/badge.svg)](https://github.com/plotly/Dash.jl/actions/workflows/jl_test.yml)
34
[![CircleCI](https://circleci.com/gh/plotly/Dash.jl/tree/master.svg?style=svg)](https://circleci.com/gh/plotly/Dash.jl/tree/master)
45
[![GitHub](https://img.shields.io/github/license/plotly/dashR.svg?color=dark-green)](https://github.com/plotly/Dash.jl/blob/master/LICENSE)
56
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/plotly/Dash.jl.svg?color=dark-green)](https://github.com/plotly/Dash.jl/graphs/contributors)

src/HttpHelpers/HttpHelpers.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module HttpHelpers
22

3-
export state_handler, exception_handling_handler, compress_handler, Route, Router, add_route!
3+
export state_handler, exception_handling_handler, compress_handler, Route, Router, add_route!, handle
44

55
import HTTP, CodecZlib
6-
76
include("handlers.jl")
87
include("router.jl")
98

10-
end
9+
end

src/HttpHelpers/handlers.jl

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1+
struct RequestHandlerFunction <: HTTP.Handler
2+
func::Function # func(req)
3+
end
4+
(x::RequestHandlerFunction)(args...) = x.func(args...)
5+
6+
function handle(h::RequestHandlerFunction, request::HTTP.Request, args...)
7+
h(request, args...)
8+
end
9+
10+
function handle(handler::Function, request::HTTP.Request, args...)
11+
handler(request, args)
12+
end
13+
14+
function handle(h::RequestHandlerFunction, request::HTTP.Request, state, args...)
15+
h(request, state, args...)
16+
end
17+
18+
function handle(handler::Function, request::HTTP.Request, state, args...)
19+
handler(request, state, args)
20+
end
21+
122
function state_handler(base_handler, state)
2-
return HTTP.RequestHandlerFunction(
23+
return RequestHandlerFunction(
324
function(request::HTTP.Request, args...)
4-
response = HTTP.handle(base_handler, request, state, args...)
25+
response = handle(base_handler, request, state, args...)
526
if response.status == 200
627
HTTP.defaultheader!(response, "Content-Type" => HTTP.sniff(response.body))
728
HTTP.defaultheader!(response, "Content-Length" => string(sizeof(response.body)))
@@ -11,7 +32,7 @@ function state_handler(base_handler, state)
1132
)
1233
end
1334

14-
state_handler(base_handler::Function, state) = state_handler(HTTP.RequestHandlerFunction(base_handler), state)
35+
state_handler(base_handler::Function, state) = state_handler(RequestHandlerFunction(base_handler), state)
1536

1637
function check_mime(message::HTTP.Message, mime_list)
1738
!HTTP.hasheader(message, "Content-Type") && return false
@@ -22,9 +43,9 @@ end
2243

2344
const default_compress_mimes = ["text/plain", "text/html", "text/css", "text/xml", "application/json", "application/javascript", "application/css"]
2445
function compress_handler(base_handler; mime_types::Vector{String} = default_compress_mimes, compress_min_size = 500)
25-
return HTTP.RequestHandlerFunction(
46+
return RequestHandlerFunction(
2647
function(request::HTTP.Request, args...)
27-
response = HTTP.handle(base_handler, request, args...)
48+
response = handle(base_handler, request, args...)
2849
if response.status == 200 && sizeof(response.body) >= compress_min_size &&
2950
occursin("gzip", HTTP.header(request, "Accept-Encoding", "")) && check_mime(response, mime_types)
3051
HTTP.setheader(response, "Content-Encoding" => "gzip")
@@ -38,14 +59,14 @@ function compress_handler(base_handler; mime_types::Vector{String} = default_com
3859
end
3960

4061
function compress_handler(base_handler::Function; mime_types::Vector{String} = default_compress_mimes, compress_min_size = 500)
41-
return compress_handler(HTTP.RequestHandlerFunction(base_handler), mime_types = mime_types, compress_min_size = compress_min_size)
62+
return compress_handler(RequestHandlerFunction(base_handler), mime_types = mime_types, compress_min_size = compress_min_size)
4263
end
4364

4465
function exception_handling_handler(ex_handling_func, base_handler)
45-
return HTTP.RequestHandlerFunction(
66+
return RequestHandlerFunction(
4667
function(request::HTTP.Request, args...)
4768
try
48-
return HTTP.handle(base_handler, request, args...)
69+
return handle(base_handler, request, args...)
4970
catch e
5071
return ex_handling_func(e)
5172
end
@@ -55,12 +76,12 @@ function exception_handling_handler(ex_handling_func, base_handler)
5576
end
5677

5778
exception_handling_handler(ex_handling_func, base_handler::Function) =
58-
exception_handling_handler(ex_handling_func, HTTP.RequestHandlerFunction(base_handler))
79+
exception_handling_handler(ex_handling_func, RequestHandlerFunction(base_handler))
5980

6081
function request_logging_handler(base_handler; exclude = Regex[])
61-
return HTTP.RequestHandlerFunction(
82+
return RequestHandlerFunction(
6283
function(request::HTTP.Request, args...)
63-
response = HTTP.handle(base_handler, request, args...)
84+
response = handle(base_handler, request, args...)
6485

6586
return response
6687
end

src/HttpHelpers/router.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ end
124124
add_route!(handler::Function, router::Router, method, url) = add_route!(router, Route(handler, method, url))
125125
add_route!(handler::Function, router::Router, url) = add_route!(handler, router, nothing, url)
126126

127-
function HTTP.handle(router::Router, request::HTTP.Request, args...)
127+
function handle(router::Router, request::HTTP.Request, args...)
128128
path = HTTP.URI(request.target).path
129129
return handle(router.routes, path, request, args...)
130130
end

src/handler/make_handler.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function make_handler(app::DashApp, registry::ResourcesRegistry; check_layout =
147147

148148
compile_request = HTTP.Request("GET", prefix)
149149
HTTP.setheader(compile_request, "Accept-Encoding" => "gzip")
150-
HTTP.handle(handler, compile_request) #For handler precompilation
150+
handle(handler, compile_request) #For handler precompilation
151151

152152
get_devsetting(app, :hot_reload) && start_reload_poll(state)
153153

src/server.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function run_server(app::DashApp,
5252
start_server = () -> begin
5353
handler = make_handler(app);
5454
server = Sockets.listen(get_inetaddr(host, port))
55-
task = @async HTTP.serve(handler, host, port; server = server, verbose = true)
55+
task = @async HTTP.serve(handler, host, port; server = server)
5656
return (server, task)
5757
end
5858

test/callbacks.jl

+15-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using Dash
2121

2222
handler = make_handler(app)
2323
request = HTTP.Request("GET", "/_dash-dependencies")
24-
resp = HTTP.handle(handler, request)
24+
resp = Dash.HttpHelpers.handle(handler, request)
2525
deps = JSON3.read(String(resp.body))
2626
@test deps[1].prevent_initial_call == false
2727
@test deps[2].prevent_initial_call == false
@@ -43,7 +43,7 @@ using Dash
4343

4444
handler = make_handler(app)
4545
request = HTTP.Request("GET", "/_dash-dependencies")
46-
resp = HTTP.handle(handler, request)
46+
resp = Dash.HttpHelpers.handle(handler, request)
4747
deps = JSON3.read(String(resp.body))
4848
@test deps[1].prevent_initial_call == true
4949
@test deps[2].prevent_initial_call == false
@@ -65,7 +65,7 @@ using Dash
6565

6666
handler = make_handler(app)
6767
request = HTTP.Request("GET", "/_dash-dependencies")
68-
resp = HTTP.handle(handler, request)
68+
resp = Dash.HttpHelpers.handle(handler, request)
6969
deps = JSON3.read(String(resp.body))
7070
@test deps[1].prevent_initial_call == true
7171
@test deps[2].prevent_initial_call == true
@@ -87,7 +87,7 @@ using Dash
8787

8888
handler = make_handler(app)
8989
request = HTTP.Request("GET", "/_dash-dependencies")
90-
resp = HTTP.handle(handler, request)
90+
resp = Dash.HttpHelpers.handle(handler, request)
9191
deps = JSON3.read(String(resp.body))
9292
@test deps[1].prevent_initial_call == true
9393
@test deps[2].prevent_initial_call == false
@@ -110,7 +110,7 @@ end
110110

111111
handler = make_handler(app)
112112
request = HTTP.Request("GET", "/_dash-dependencies")
113-
resp = HTTP.handle(handler, request)
113+
resp = Dash.HttpHelpers.handle(handler, request)
114114
deps = JSON3.read(String(resp.body))
115115

116116
@test length(deps) == 1
@@ -124,7 +124,7 @@ end
124124
handler = Dash.make_handler(app)
125125
test_json = """{"output":"my-div.children","changedPropIds":["my-id.value"],"inputs":[{"id":"my-id","property":"value","value":"test"}]}"""
126126
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
127-
response = HTTP.handle(handler, request)
127+
response = Dash.HttpHelpers.handle(handler, request)
128128
@test response.status == 200
129129
resp_obj = JSON3.read(String(response.body))
130130
@test in(:multi, keys(resp_obj))
@@ -149,7 +149,7 @@ end
149149
handler = Dash.make_handler(app)
150150
test_json = """{"output":"..my-div.children...my-div2.children..","changedPropIds":["my-id.value"],"inputs":[{"id":"my-id","property":"value","value":"test"}], "state":[{"id":"my-id","property":"type","value":"state"}]}"""
151151
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
152-
response = HTTP.handle(handler, request)
152+
response = Dash.HttpHelpers.handle(handler, request)
153153
@test response.status == 200
154154
resp_obj = JSON3.read(String(response.body))
155155
@test in(:multi, keys(resp_obj))
@@ -172,7 +172,7 @@ end
172172
handler = Dash.make_handler(app)
173173
test_json = """{"output":"..my-div.children..","changedPropIds":["my-id.value"],"inputs":[{"id":"my-id","property":"value","value":"test"}], "state":[{"id":"my-id","property":"type","value":"state"}]}"""
174174
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
175-
response = HTTP.handle(handler, request)
175+
response = Dash.HttpHelpers.handle(handler, request)
176176
@test response.status == 200
177177
resp_obj = JSON3.read(String(response.body))
178178
@test in(:multi, keys(resp_obj))
@@ -350,7 +350,7 @@ end
350350
)
351351
test_json = JSON3.write(request)
352352
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
353-
response = HTTP.handle(handler, request)
353+
response = Dash.HttpHelpers.handle(handler, request)
354354

355355
@test response.status == 200
356356

@@ -389,7 +389,7 @@ end
389389
)
390390
test_json = JSON3.write(request)
391391
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
392-
response = HTTP.handle(handler, request)
392+
response = Dash.HttpHelpers.handle(handler, request)
393393

394394
@test response.status == 200
395395
resp_obj = JSON3.read(String(response.body))
@@ -441,7 +441,7 @@ end
441441
)
442442
test_json = JSON3.write(request)
443443
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
444-
response = HTTP.handle(handler, request)
444+
response = Dash.HttpHelpers.handle(handler, request)
445445
@test response.status == 200
446446
s = String(response.body)
447447
resp_obj = JSON3.read(s)
@@ -494,7 +494,7 @@ end
494494
)
495495
test_json = JSON3.write(request)
496496
request = HTTP.Request("POST", "/_dash-update-component", [], Vector{UInt8}(test_json))
497-
response = HTTP.handle(handler, request)
497+
response = Dash.HttpHelpers.handle(handler, request)
498498
@test response.status == 200
499499
resp_obj = JSON3.read(String(response.body))
500500
@test in(:multi, keys(resp_obj))
@@ -597,7 +597,7 @@ end
597597

598598
handler = make_handler(app)
599599
request = HTTP.Request("GET", "/_dash-dependencies")
600-
resp = HTTP.handle(handler, request)
600+
resp = Dash.HttpHelpers.handle(handler, request)
601601
deps = JSON3.read(String(resp.body))
602602

603603
@test length(deps) == 1
@@ -640,7 +640,7 @@ end
640640

641641
handler = make_handler(app)
642642
request = HTTP.Request("GET", "/_dash-dependencies")
643-
resp = HTTP.handle(handler, request)
643+
resp = Dash.HttpHelpers.handle(handler, request)
644644
deps = JSON3.read(String(resp.body))
645645

646646
@test length(deps) == 1
@@ -652,7 +652,7 @@ end
652652
@test cb.clientside_function.namespace == "_dashprivate_my-div"
653653
@test cb.clientside_function.function_name == "children"
654654
request = HTTP.Request("GET", "/")
655-
resp = HTTP.handle(handler, request)
655+
resp = Dash.HttpHelpers.handle(handler, request)
656656
body = String(resp.body)
657657
@test occursin("clientside[\"_dashprivate_my-div\"]", body)
658658
@test occursin("ns[\"children\"]", body)

0 commit comments

Comments
 (0)