Skip to content

Commit

Permalink
Merge pull request #68 from JuliaWeb/rd/mime
Browse files Browse the repository at this point in the history
Port MIME type detection over from HttpServer.jl
  • Loading branch information
rdeits authored Aug 22, 2018
2 parents 962b54f + 4bbd9e5 commit 7fdabed
Show file tree
Hide file tree
Showing 4 changed files with 1,017 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Mux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include("routing.jl")

include("websockets_integration.jl")

include("examples/mimetypes.jl")
include("examples/basic.jl")
include("examples/files.jl")

Expand Down
5 changes: 2 additions & 3 deletions src/examples/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ function validpath(root, path; dirs = true)
(isfile(full) || (dirs && isdir(full)))
end

ormatch(r::RegexMatch, x) = r.match
ormatch(r::Nothing, x) = x
extension(f) = last(splitext(f))[2:end]

fileheaders(f) = d("Content-Type" => "application/octet-stream") # TODO: switch to using HTTP.sniff
fileheaders(f) = d("Content-Type" => get(mimetypes, extension(f), "application/octet-stream"))

fileresponse(f) = d(:file => f,
:body => read(f),
Expand Down
Loading

0 comments on commit 7fdabed

Please sign in to comment.