How to serve a file with specific MIME / media type in Genie?

Hi all,

I am still new to the Julia web stack – namely, the Genie and HTTP packages.

I know that it is possible to serve an HTML file with media type text/html from, say, the root directory / using:

route("/") do

Here are my questions:

  • How does Genie know which media type to serve the file with? Is it auto-detected from the file extension .html or is it some other process?

  • Suppose I want to serve a file called data.trig with the media type application/trig on the route /data. Or, more generally, any HTTP response where I have modified the response headers and body to my liking. What is the proper way to go about this?

(I am still new to the Julia web stack, so any resources on how to modify response headers in Genie.jl or HTTP.jl would be welcome also.)

Thanks in advance!