From 8a7ba5d0307b32d16e0c1a56f8b40241a0ea6fa9 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Thu, 4 Mar 2021 18:31:35 +0300 Subject: [PATCH 1/2] Fix media types --- model/src/main/kotlin/io/kotless/HTTP.kt | 4 ++-- .../test/resources/examples/kotless/shortener/shortener.tf | 2 +- .../gradle/src/test/resources/examples/kotless/site/site.tf | 2 +- .../src/test/resources/examples/ktor/shortener/shortener.tf | 2 +- plugins/gradle/src/test/resources/examples/ktor/site/site.tf | 2 +- .../src/test/resources/examples/spring/shortener/shortener.tf | 2 +- .../gradle/src/test/resources/examples/spring/site/site.tf | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/model/src/main/kotlin/io/kotless/HTTP.kt b/model/src/main/kotlin/io/kotless/HTTP.kt index 598571f4..614e6c39 100644 --- a/model/src/main/kotlin/io/kotless/HTTP.kt +++ b/model/src/main/kotlin/io/kotless/HTTP.kt @@ -24,7 +24,7 @@ enum class MimeType(val mimeText: String, val isBinary: Boolean, val extension: PNG("image/png", true, "png"), APNG("image/apng", true, "apng"), GIF("image/gif", true, "gif"), - SVG("image/svg", true, "svg"), + SVG("image/svg+xml", false, "svg"), JPEG("image/jpeg", true, "jpeg"), BMP("image/bmp", true, "bmp"), WEBP("image/webp", true, "webp"), @@ -35,7 +35,7 @@ enum class MimeType(val mimeText: String, val isBinary: Boolean, val extension: JSON("application/json", false, "json"), XML("application/xml", false, "xml"), ZIP("application/zip", true, "zip"), - GZIP("application/gzip", true, "gzip"); + GZIP("application/gzip", true, "gz"); companion object { fun binary() = values().filter { it.isBinary }.toTypedArray() diff --git a/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf b/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf index 0464e87f..533dbf4e 100644 --- a/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf +++ b/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf @@ -268,7 +268,7 @@ resource "aws_api_gateway_resource" "shorten" { } resource "aws_api_gateway_rest_api" "shortener" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg", "image/webp"] + binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] name = "short-shortener" } diff --git a/plugins/gradle/src/test/resources/examples/kotless/site/site.tf b/plugins/gradle/src/test/resources/examples/kotless/site/site.tf index 28b2c4dd..c7bdf2e6 100644 --- a/plugins/gradle/src/test/resources/examples/kotless/site/site.tf +++ b/plugins/gradle/src/test/resources/examples/kotless/site/site.tf @@ -564,7 +564,7 @@ resource "aws_api_gateway_resource" "pages_plugin_tasks" { } resource "aws_api_gateway_rest_api" "site" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg", "image/webp"] + binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] name = "site-site" } diff --git a/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf b/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf index d795a355..40c139ac 100644 --- a/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf +++ b/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf @@ -268,7 +268,7 @@ resource "aws_api_gateway_resource" "shorten" { } resource "aws_api_gateway_rest_api" "shortener" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg", "image/webp"] + binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] name = "ktor-short-shortener" } diff --git a/plugins/gradle/src/test/resources/examples/ktor/site/site.tf b/plugins/gradle/src/test/resources/examples/ktor/site/site.tf index 011db46d..e2d8580b 100644 --- a/plugins/gradle/src/test/resources/examples/ktor/site/site.tf +++ b/plugins/gradle/src/test/resources/examples/ktor/site/site.tf @@ -564,7 +564,7 @@ resource "aws_api_gateway_resource" "pages_plugin_tasks" { } resource "aws_api_gateway_rest_api" "site" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg", "image/webp"] + binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] name = "ktor-site-site" } diff --git a/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf b/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf index f67c865d..49eae673 100644 --- a/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf +++ b/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf @@ -268,7 +268,7 @@ resource "aws_api_gateway_resource" "shorten" { } resource "aws_api_gateway_rest_api" "shortener" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg", "image/webp"] + binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] name = "spring-short-shortener" } diff --git a/plugins/gradle/src/test/resources/examples/spring/site/site.tf b/plugins/gradle/src/test/resources/examples/spring/site/site.tf index 820c5afe..5b80278f 100644 --- a/plugins/gradle/src/test/resources/examples/spring/site/site.tf +++ b/plugins/gradle/src/test/resources/examples/spring/site/site.tf @@ -564,7 +564,7 @@ resource "aws_api_gateway_resource" "pages_plugin_tasks" { } resource "aws_api_gateway_rest_api" "site" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg", "image/webp"] + binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] name = "spring-site-site" } From 1a6b00ab32c3cd2de96321c1679109c6d8887ab6 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Fri, 5 Mar 2021 15:19:39 +0300 Subject: [PATCH 2/2] Add popular media types --- model/src/main/kotlin/io/kotless/HTTP.kt | 23 +++++++++++++++++++ .../examples/kotless/shortener/shortener.tf | 2 +- .../resources/examples/kotless/site/site.tf | 2 +- .../examples/ktor/shortener/shortener.tf | 2 +- .../test/resources/examples/ktor/site/site.tf | 2 +- .../examples/spring/shortener/shortener.tf | 2 +- .../resources/examples/spring/site/site.tf | 2 +- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/model/src/main/kotlin/io/kotless/HTTP.kt b/model/src/main/kotlin/io/kotless/HTTP.kt index 614e6c39..fccdeaa3 100644 --- a/model/src/main/kotlin/io/kotless/HTTP.kt +++ b/model/src/main/kotlin/io/kotless/HTTP.kt @@ -20,20 +20,43 @@ enum class MimeType(val mimeText: String, val isBinary: Boolean, val extension: MARKDOWN("text/markdown", false, "md"), HTML("text/html", false, "html"), CSS("text/css", false, "css"), + CSV("text/csv", false, "csv"), + ICS("text/calendar", false, "ics"), PNG("image/png", true, "png"), APNG("image/apng", true, "apng"), GIF("image/gif", true, "gif"), SVG("image/svg+xml", false, "svg"), JPEG("image/jpeg", true, "jpeg"), + HEIC("image/heic", true, "heic"), + ICO("image/vnd.microsoft.icon", true, "ico"), BMP("image/bmp", true, "bmp"), + MPEG("audio/mpeg",true, "mp3"), + M4A("audio/mp4", true, "m4a"), + MP4("video/mp4", true, "mp4"), + AAC("audio/aac", true, "aac"), WEBP("image/webp", true, "webp"), + WEBA("audio/webm", true, "weba"), + WEBM("video/webm", true, "webm"), TTF("font/ttf", true, "ttf"), + WOFF("font/woff", true, "woff"), + WOFF2("font/woff2", true, "woff2"), + + DOC("application/msword",true, "doc"), + DOCX("application/vnd.openxmlformats-officedocument.wordprocessingml.document",true, "docx"), + PPT("application/vnd.ms-powerpoint",true,"ppt"), + PPTX("application/vnd.openxmlformats-officedocument.presentationml.presentation", true, "pptx"), + XLS("application/vnd.ms-excel", true, "xls"), + XLSX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", true, "xlsx"), + PDF("application/pdf", true, "pdf"), + EPUB("application/epub+zip",true, "epub"), JS("application/javascript", false, "js"), JSMAP("application/json", false, "map"), JSON("application/json", false, "json"), XML("application/xml", false, "xml"), + SHELL("application/x-shellscript", false,"sh"), + JAR("application/java-archive", true, "jar"), ZIP("application/zip", true, "zip"), GZIP("application/gzip", true, "gz"); diff --git a/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf b/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf index 533dbf4e..570d4836 100644 --- a/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf +++ b/plugins/gradle/src/test/resources/examples/kotless/shortener/shortener.tf @@ -268,7 +268,7 @@ resource "aws_api_gateway_resource" "shorten" { } resource "aws_api_gateway_rest_api" "shortener" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] + binary_media_types = ["application/epub+zip", "application/gzip", "application/java-archive", "application/msword", "application/pdf", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip", "audio/aac", "audio/mp4", "audio/mpeg", "audio/webm", "font/ttf", "font/woff", "font/woff2", "image/apng", "image/bmp", "image/gif", "image/heic", "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/webp", "video/mp4", "video/webm"] name = "short-shortener" } diff --git a/plugins/gradle/src/test/resources/examples/kotless/site/site.tf b/plugins/gradle/src/test/resources/examples/kotless/site/site.tf index c7bdf2e6..df29965a 100644 --- a/plugins/gradle/src/test/resources/examples/kotless/site/site.tf +++ b/plugins/gradle/src/test/resources/examples/kotless/site/site.tf @@ -564,7 +564,7 @@ resource "aws_api_gateway_resource" "pages_plugin_tasks" { } resource "aws_api_gateway_rest_api" "site" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] + binary_media_types = ["application/epub+zip", "application/gzip", "application/java-archive", "application/msword", "application/pdf", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip", "audio/aac", "audio/mp4", "audio/mpeg", "audio/webm", "font/ttf", "font/woff", "font/woff2", "image/apng", "image/bmp", "image/gif", "image/heic", "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/webp", "video/mp4", "video/webm"] name = "site-site" } diff --git a/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf b/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf index 40c139ac..09dabb57 100644 --- a/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf +++ b/plugins/gradle/src/test/resources/examples/ktor/shortener/shortener.tf @@ -268,7 +268,7 @@ resource "aws_api_gateway_resource" "shorten" { } resource "aws_api_gateway_rest_api" "shortener" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] + binary_media_types = ["application/epub+zip", "application/gzip", "application/java-archive", "application/msword", "application/pdf", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip", "audio/aac", "audio/mp4", "audio/mpeg", "audio/webm", "font/ttf", "font/woff", "font/woff2", "image/apng", "image/bmp", "image/gif", "image/heic", "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/webp", "video/mp4", "video/webm"] name = "ktor-short-shortener" } diff --git a/plugins/gradle/src/test/resources/examples/ktor/site/site.tf b/plugins/gradle/src/test/resources/examples/ktor/site/site.tf index e2d8580b..f2c08f55 100644 --- a/plugins/gradle/src/test/resources/examples/ktor/site/site.tf +++ b/plugins/gradle/src/test/resources/examples/ktor/site/site.tf @@ -564,7 +564,7 @@ resource "aws_api_gateway_resource" "pages_plugin_tasks" { } resource "aws_api_gateway_rest_api" "site" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] + binary_media_types = ["application/epub+zip", "application/gzip", "application/java-archive", "application/msword", "application/pdf", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip", "audio/aac", "audio/mp4", "audio/mpeg", "audio/webm", "font/ttf", "font/woff", "font/woff2", "image/apng", "image/bmp", "image/gif", "image/heic", "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/webp", "video/mp4", "video/webm"] name = "ktor-site-site" } diff --git a/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf b/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf index 49eae673..170ae5e0 100644 --- a/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf +++ b/plugins/gradle/src/test/resources/examples/spring/shortener/shortener.tf @@ -268,7 +268,7 @@ resource "aws_api_gateway_resource" "shorten" { } resource "aws_api_gateway_rest_api" "shortener" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] + binary_media_types = ["application/epub+zip", "application/gzip", "application/java-archive", "application/msword", "application/pdf", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip", "audio/aac", "audio/mp4", "audio/mpeg", "audio/webm", "font/ttf", "font/woff", "font/woff2", "image/apng", "image/bmp", "image/gif", "image/heic", "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/webp", "video/mp4", "video/webm"] name = "spring-short-shortener" } diff --git a/plugins/gradle/src/test/resources/examples/spring/site/site.tf b/plugins/gradle/src/test/resources/examples/spring/site/site.tf index 5b80278f..a747a3c5 100644 --- a/plugins/gradle/src/test/resources/examples/spring/site/site.tf +++ b/plugins/gradle/src/test/resources/examples/spring/site/site.tf @@ -564,7 +564,7 @@ resource "aws_api_gateway_resource" "pages_plugin_tasks" { } resource "aws_api_gateway_rest_api" "site" { - binary_media_types = ["application/gzip", "application/zip", "font/ttf", "image/apng", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"] + binary_media_types = ["application/epub+zip", "application/gzip", "application/java-archive", "application/msword", "application/pdf", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip", "audio/aac", "audio/mp4", "audio/mpeg", "audio/webm", "font/ttf", "font/woff", "font/woff2", "image/apng", "image/bmp", "image/gif", "image/heic", "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/webp", "video/mp4", "video/webm"] name = "spring-site-site" }