Skip to content

Commit

Permalink
feat: adding zip gzip and gpx to MediaType (#10747)
Browse files Browse the repository at this point in the history
Close: #10673
  • Loading branch information
PeterFokkinga authored Apr 24, 2024
1 parent f7dbe03 commit 336907a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
51 changes: 51 additions & 0 deletions http/src/main/java/io/micronaut/http/MediaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ public class MediaType implements CharSequence {
*/
public static final String EXTENSION_XLS = "xls";

/**
* File extension for GPS Exchange Format files.
*/
public static final String EXTENSION_GPX = "gpx";

/**
* File extension for ZIP archive files.
*/
public static final String EXTENSION_ZIP = "zip";

/**
* File extension for GZIP compressed files.
*/
public static final String EXTENSION_GZIP = "gz";

/**
* Default empty media type array.
*/
Expand Down Expand Up @@ -424,6 +439,36 @@ public class MediaType implements CharSequence {
*/
public static final MediaType IMAGE_WEBP_TYPE = new MediaType(IMAGE_WEBP);

/**
* GPS Exchange Format: application/gpx+xml.
*/
public static final String APPLICATION_GPX_XML = "application/gpx+xml";

/**
* GPS Exchange Format: application/gpx+xml.
*/
public static final MediaType GPX_XML_TYPE = new MediaType(APPLICATION_GPX_XML, EXTENSION_GPX);

/**
* ZIP archive format: application/zip.
*/
public static final String APPLICATION_ZIP = "application/zip";

/**
* ZIP archive format: application/zip.
*/
public static final MediaType ZIP_TYPE = new MediaType(APPLICATION_ZIP);

/**
* GZip compressed data: application/gzip.
*/
public static final String APPLICATION_GZIP = "application/gzip";

/**
* GZip compressed data: application/gzip.
*/
public static final MediaType GZIP_TYPE = new MediaType(APPLICATION_GZIP);

/**
* Parameter {@code "charset"}.
*/
Expand Down Expand Up @@ -645,6 +690,12 @@ public static MediaType of(String mediaType) {
return IMAGE_GIF_TYPE;
case IMAGE_WEBP:
return IMAGE_WEBP_TYPE;
case APPLICATION_GPX_XML:
return GPX_XML_TYPE;
case APPLICATION_GZIP:
return GZIP_TYPE;
case APPLICATION_ZIP:
return ZIP_TYPE;
default:
return new MediaType(mediaType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.util.ArrayUtils;
import io.micronaut.core.util.CollectionUtils;
import io.micronaut.core.util.ObjectUtils;

Expand Down
2 changes: 1 addition & 1 deletion http/src/main/resources/META-INF/http/mime.types
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ application/font-tdpfr pfr
application/gml+xml gml
application/gpx+xml gpx
application/gxf gxf
# application/gzip
application/gzip gz
# application/h224
# application/held+xml
# application/http
Expand Down

0 comments on commit 336907a

Please sign in to comment.