Skip to content

Commit

Permalink
Introduce HTTPExt package extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Drvi committed Nov 13, 2024
1 parent 50ea61f commit dca4c62
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name = "FileIO"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.16.5"
version = "1.16.6"

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

[weakdeps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"

[extensions]
HTTPExt = "HTTP"

[compat]
Pkg = "<0.0.1, 0.7, 1"
Requires = "1"
Expand Down
13 changes: 13 additions & 0 deletions ext/HTTPExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module HTTPExt

if isdefined(Base, :get_extension)
using FileIO
using HTTP
else
using ..FileIO
using ..HTTP
end

FileIO.load(uri::HTTP.URI) = load(IOBuffer(HTTP.get(uri).body))

end # module
4 changes: 3 additions & 1 deletion src/FileIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ include("registry.jl")
"""
FileIO

@static if !isdefined(Base, :get_extension)
function __init__()
@require HTTP="cd3eb016-35fb-5094-929b-558a96fad6f3" begin
load(uri::HTTP.URI) = load(IOBuffer(HTTP.get(uri).body))
include("../ext/HTTPExt.jl")

Check warning on line 70 in src/FileIO.jl

View check run for this annotation

Codecov / codecov/patch

src/FileIO.jl#L70

Added line #L70 was not covered by tests
end
end
end # @static

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

0 comments on commit dca4c62

Please sign in to comment.