Skip to content

Feature: serve_file #567

Open
Open
@chris-b1

Description

@chris-b1

This seems like generic enough functionality it could make sense to put in HTTP.jl. I don't have an api figured out, but just as a placeholder/starting point

# ?serve_file
#     serve_file(path; mimetype="infer", extension="infer", ...) :: HTTP.Response
#     serve_file(stream::HTTP.Stream, ...) :: Nothing

using HTTP

function handle_file(req::HTTP.Request)
    return HTTP.serve_file("file.txt") 
end

Some pointers to other implementations

PkgServer - https://github.com/JuliaPackaging/PkgServer.jl/blob/065235d39b4f66018dbc51ce3cb6861429f095e2/src/resource.jl#L394

Genie - https://github.com/GenieFramework/Genie.jl/blob/899ea32d3a7a95aab3bfe508fc9d6821bde2a1e0/src/Router.jl#L992

Flask - https://github.com/pallets/flask/blob/632f85b65354ad573bb33c54a0a9dd3ffcef371f/src/flask/helpers.py#L447

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions