Skip to content

Commit 1750ca1

Browse files
committed
Provide scheme to host param
1 parent 8866708 commit 1750ca1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/PlutoRESTClient.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export PlutoNotebook, @resolve
88

99

1010
"""
11-
evaluate(output::Symbol, filename::AbstractString, host::AbstractString="localhost:1234"; kwargs...)
11+
evaluate(output::Symbol, filename::AbstractString, host::AbstractString="http://localhost:1234"; kwargs...)
1212
1313
Function equivalent of syntax described in documentation for `PlutoNotebook`.
1414
@@ -21,8 +21,8 @@ julia> PlutoRESTClient.evaluate(:c, "EuclideanDistance.jl"; a=5., b=12.)
2121
13.0
2222
```
2323
"""
24-
function evaluate(output::Symbol, filename::AbstractString, host::AbstractString="localhost:1234"; kwargs...)
25-
request_uri = HTTP.URI("http://$(host)/v1/notebook/$(HTTP.escapeuri(filename))/eval")
24+
function evaluate(output::Symbol, filename::AbstractString, host::AbstractString="http://localhost:1234"; kwargs...)
25+
request_uri = HTTP.URI("$(host)/v1/notebook/$(HTTP.escapeuri(filename))/eval")
2626

2727
body = IOBuffer()
2828
Serialization.serialize(body, Dict{String, Any}(
@@ -44,12 +44,12 @@ function evaluate(output::Symbol, filename::AbstractString, host::AbstractString
4444
end
4545

4646
"""
47-
call(fn_name::Symbol, args::Tuple, kwargs::Iterators.Pairs, filename::AbstractString, host::AbstractString="localhost:1234")
47+
call(fn_name::Symbol, args::Tuple, kwargs::Iterators.Pairs, filename::AbstractString, host::AbstractString="http://localhost:1234")
4848
4949
Function equivalent of syntax described in documentation for `PlutoCallable`.
5050
"""
51-
function call(fn_name::Symbol, args::Tuple, kwargs::Iterators.Pairs, filename::AbstractString, host::AbstractString="localhost:1234")
52-
request_uri = HTTP.URI("http://$(host)/v1/notebook/$(HTTP.escapeuri(filename))/call")
51+
function call(fn_name::Symbol, args::Tuple, kwargs::Iterators.Pairs, filename::AbstractString, host::AbstractString="http://localhost:1234")
52+
request_uri = HTTP.URI("$(host)/v1/notebook/$(HTTP.escapeuri(filename))/call")
5353

5454
body = IOBuffer()
5555
Serialization.serialize(body, Dict{String, Any}(
@@ -72,23 +72,23 @@ function call(fn_name::Symbol, args::Tuple, kwargs::Iterators.Pairs, filename::A
7272
end
7373

7474
"""
75-
static_function(output::Symbol, inputs::Vector{Symbol}, filename::AbstractString, host::AbstractString="localhost:1234")
75+
static_function(output::Symbol, inputs::Vector{Symbol}, filename::AbstractString, host::AbstractString="http://localhost:1234")
7676
7777
Returns the code for a function which uses the relevant Pluto notebook code to compute the value of `output` given `inputs` as parameters.
7878
This function is what the [`@resolve`](@ref) macro calls under-the-hood, whcih subsequently passes the result into `eval`.
7979
"""
80-
function static_function(output::Symbol, inputs::Vector{Symbol}, filename::AbstractString, host::AbstractString="localhost:1234")
80+
function static_function(output::Symbol, inputs::Vector{Symbol}, filename::AbstractString, host::AbstractString="http://localhost:1234")
8181
@warn "Ensure you trust this host, as the function returned could be malicious"
8282

8383
query = ["outputs" => String(output), "inputs" => join(inputs, ",")]
84-
request_uri = merge(HTTP.URI("http://$(host)/v1/notebook/$filename/static"); query=query)
84+
request_uri = merge(HTTP.URI("$(host)/v1/notebook/$filename/static"); query=query)
8585
response = HTTP.get(request_uri)
8686

8787
Meta.parse(String(response.body))
8888
end
8989

9090
"""
91-
PlutoNotebook(filename::AbstractString, host::AbstractString="localhost:1234")
91+
PlutoNotebook(filename::AbstractString, host::AbstractString="http://localhost:1234")
9292
9393
Reference a Pluto notebook running on a Pluto server somewhere.
9494
@@ -107,7 +107,7 @@ struct PlutoNotebook
107107
host::AbstractString
108108
filename::AbstractString
109109

110-
PlutoNotebook(filename::AbstractString, host::AbstractString="localhost:1234") = new(host, filename)
110+
PlutoNotebook(filename::AbstractString, host::AbstractString="http://localhost:1234") = new(host, filename)
111111
end
112112
function Base.getproperty(notebook::PlutoNotebook, symbol::Symbol)
113113
Base.getproperty(notebook(), symbol)
@@ -131,7 +131,7 @@ From elsewhere the `PlutoCallable` structure can be called as a function in itse
131131
julia> nb = PlutoNotebook("EuclideanDistance.jl");
132132
133133
julia> nb.distance
134-
Pluto.PlutoCallable(PlutoNotebook("localhost:1234", "EuclideanDistance.jl"), :distance)
134+
Pluto.PlutoCallable(PlutoNotebook("http://localhost:1234", "EuclideanDistance.jl"), :distance)
135135
136136
julia> nb.distance(5., 12.)
137137
13.0
@@ -155,7 +155,7 @@ An intermediate structure which is returned when one calls a `PlutoNotebook` as
155155
julia> nb = PlutoNotebook("EuclideanDistance.jl");
156156
157157
julia> nb_withargs = nb(; a=5., b=12.)
158-
Pluto.PlutoNotebookWithArgs(PlutoNotebook("localhost:1234", "EuclideanDistance.jl"), Dict{Symbol, Any}(:a => 5.0, :b => 12.0))
158+
Pluto.PlutoNotebookWithArgs(PlutoNotebook("http://localhost:1234", "EuclideanDistance.jl"), Dict{Symbol, Any}(:a => 5.0, :b => 12.0))
159159
160160
julia> nb_withargs.c
161161
13.0

0 commit comments

Comments
 (0)