Skip to content

Commit 8840934

Browse files
authored
Merge pull request #403 from Drvi/td-http-ext
Introduce `HTTPExt` package extension
2 parents ef06d2d + 8d5c9fc commit 8840934

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

Project.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
name = "FileIO"
22
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
3-
version = "1.16.5"
3+
version = "1.16.6"
44

55
[deps]
66
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
77
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
88
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
99

10+
[weakdeps]
11+
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
12+
13+
[extensions]
14+
HTTPExt = "HTTP"
15+
1016
[compat]
1117
Pkg = "<0.0.1, 0.7, 1"
1218
Requires = "1"

docs/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ PNGFiles = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
66

77
[compat]
88
Documenter = "1"
9-
HTTP = "0.9"
9+
HTTP = "0.9, 1"

ext/HTTPExt.jl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module HTTPExt
2+
3+
if isdefined(Base, :get_extension)
4+
using FileIO
5+
using HTTP
6+
else
7+
using ..FileIO
8+
using ..HTTP
9+
end
10+
11+
FileIO.load(uri::HTTP.URI) = load(IOBuffer(HTTP.get(uri).body))
12+
13+
end # module

src/FileIO.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ include("registry.jl")
6464
"""
6565
FileIO
6666

67+
@static if !isdefined(Base, :get_extension)
6768
function __init__()
6869
@require HTTP="cd3eb016-35fb-5094-929b-558a96fad6f3" begin
69-
load(uri::HTTP.URI) = load(IOBuffer(HTTP.get(uri).body))
70+
include("../ext/HTTPExt.jl")
7071
end
7172
end
73+
end # @static
7274

7375
if VERSION >= v"1.4.2" # https://github.com/JuliaLang/julia/pull/35378
7476
include("precompile.jl")

0 commit comments

Comments
 (0)