Closed Cre3per closed 1 year ago
The mimemap source code in the h2o server may be helpful.
It may be a good idea to add the following MIME in as_content_type
.
geojson
as application/geo+json
gltf
as model/gltf+json
jsonld
as application/ld+json
And how about also supporting the above MIME in from_content_type
, and treating anything that ends with +json
as JSON?
FYI: https://github.com/h2o/h2o/blob/master/lib/handler/mimemap/defaults.c.h https://github.com/h2o/h2o/blob/e041bac7f7556415a201bc664d16412c5f6c62de/lib/handler/mimemap.c#L428-L435
@petamoriken deno_ast provides functionality for deno
itself, which means MediaType
only needs to support formats of scripts, configs, and so on. MediaType
isn't intended to be a general purpose type. geojson
, gltf
, and jsonld
would be unused, because deno
doesn't use these formats.
I had a quick look through media types ending in +json
and didn't see any that a web server would set when serving files used by deno
. If you know of a file where such a media type is correct, it might be worth opening a separate issue.
@Cre3per I suggested this because I thought it would be useful for displaying JSON in LSP and handling JSON in Import Assetions when developing a web application that uses geojson
, gltf
, and jsonld
. I may be misunderstanding, and as you say, it would be better to address this in a separate issue.
Closes #133
The mappings in
as_content_type()
are a suggestion based onfrom_content_type()
and web searches.Potential issues
from_file_extension()
is case-sensitive to file extensions whilefrom_path()
is case-insensitive.If the crate user has non-lower-case extensions, they can transform them once to avoid every library function from having to do the transformation.
Additional changes
Changed return type of
as_ts_extension()
to'static
. If this change is wrong, I'll also need to remove the'static
fromas_content_type()
.