Class ResourceType

    • Field Detail

      • DEFAULT_EXTENSION_MAPPINGS

        public static final java.util.Map<java.lang.String,​ResourceType> DEFAULT_EXTENSION_MAPPINGS
        The mapping of file extensions (such as "jpg") to resource types (such as IMAGE_JPEG that mu-server uses by default when serving static content.
      • AUDIO_AAC

        public static final ResourceType AUDIO_AAC
        audio/aac
      • APPLICATION_X_ABIWORD

        public static final ResourceType APPLICATION_X_ABIWORD
        application/x-abiword
      • VIDEO_X_MSVIDEO

        public static final ResourceType VIDEO_X_MSVIDEO
        video/x-msvideo
      • APPLICATION_VND_AMAZON_EBOOK

        public static final ResourceType APPLICATION_VND_AMAZON_EBOOK
        application/vnd-amazon-ebook
      • APPLICATION_OCTET_STREAM

        public static final ResourceType APPLICATION_OCTET_STREAM
        application/octet-stream
      • APPLICATION_X_BZIP

        public static final ResourceType APPLICATION_X_BZIP
        application/x-bzip
      • APPLICATION_X_BZIP2

        public static final ResourceType APPLICATION_X_BZIP2
        application/x-bzip2
      • APPLICATION_X_CSH

        public static final ResourceType APPLICATION_X_CSH
        application/x-csh
      • TEXT_CSS

        public static final ResourceType TEXT_CSS
        text/css
      • TEXT_PLAIN

        public static final ResourceType TEXT_PLAIN
        text/plain;charset=utf-8
      • TEXT_MARKDOWN

        public static final ResourceType TEXT_MARKDOWN
        text/markdown;charset=utf-8
      • TEXT_CSV

        public static final ResourceType TEXT_CSV
        text/csv;charset=utf-8
      • APPLICATION_MSWORD

        public static final ResourceType APPLICATION_MSWORD
        application/msword
      • APPLICATION_VND_MS_FONTOBJECT

        public static final ResourceType APPLICATION_VND_MS_FONTOBJECT
        application/vnd-ms-fontobject
      • APPLICATION_EPUB_ZIP

        public static final ResourceType APPLICATION_EPUB_ZIP
        application/epub-zip
      • APPLICATION_GZIP

        public static final ResourceType APPLICATION_GZIP
        application/gzip
      • IMAGE_GIF

        public static final ResourceType IMAGE_GIF
        image/gif
      • TEXT_HTML

        public static final ResourceType TEXT_HTML
        text/html;charset=utf-8
      • IMAGE_X_ICON

        public static final ResourceType IMAGE_X_ICON
        image/x-icon
      • TEXT_CALENDAR

        public static final ResourceType TEXT_CALENDAR
        text/calendar;charset=utf-8
      • APPLICATION_JAVA_ARCHIVE

        public static final ResourceType APPLICATION_JAVA_ARCHIVE
        application/java-archive
      • IMAGE_JPEG

        public static final ResourceType IMAGE_JPEG
        image/jpeg
      • APPLICATION_JAVASCRIPT

        public static final ResourceType APPLICATION_JAVASCRIPT
        application/javascript
      • APPLICATION_JSON

        public static final ResourceType APPLICATION_JSON
        application/json
      • WEB_APP_MANIFEST

        public static final ResourceType WEB_APP_MANIFEST
        web/app-manifest
      • AUDIO_MIDI

        public static final ResourceType AUDIO_MIDI
        audio/midi
      • VIDEO_MP4

        public static final ResourceType VIDEO_MP4
        video/mp4
      • VIDEO_MPEG

        public static final ResourceType VIDEO_MPEG
        video/mpeg
      • APPLICATION_VND_APPLE_INSTALLER_XML

        public static final ResourceType APPLICATION_VND_APPLE_INSTALLER_XML
        application/vnd-apple-installer-xml
      • APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION

        public static final ResourceType APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION
        application/vnd-oasis-opendocument-presentation
      • APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET

        public static final ResourceType APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET
        application/vnd-oasis-opendocument-spreadsheet
      • APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT

        public static final ResourceType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT
        application/vnd-oasis-opendocument-text
      • AUDIO_OGG

        public static final ResourceType AUDIO_OGG
        audio/ogg
      • VIDEO_X_MATROSKA

        public static final ResourceType VIDEO_X_MATROSKA
        video/x-matroska
      • VIDEO_OGG

        public static final ResourceType VIDEO_OGG
        video/ogg
      • APPLICATION_OGG

        public static final ResourceType APPLICATION_OGG
        application/ogg
      • FONT_OTF

        public static final ResourceType FONT_OTF
        font/otf
      • IMAGE_PNG

        public static final ResourceType IMAGE_PNG
        image/png
      • APPLICATION_PDF

        public static final ResourceType APPLICATION_PDF
        application/pdf
      • APPLICATION_VND_MS_POWERPOINT

        public static final ResourceType APPLICATION_VND_MS_POWERPOINT
        application/vnd-ms-powerpoint
      • APPLICATION_X_RAR_COMPRESSED

        public static final ResourceType APPLICATION_X_RAR_COMPRESSED
        application/x-rar-compressed
      • APPLICATION_RTF

        public static final ResourceType APPLICATION_RTF
        application/rtf
      • APPLICATION_X_SH

        public static final ResourceType APPLICATION_X_SH
        application/x-sh
      • IMAGE_SVG_XML

        public static final ResourceType IMAGE_SVG_XML
        image/svg-xml
      • APPLICATION_X_SHOCKWAVE_FLASH

        public static final ResourceType APPLICATION_X_SHOCKWAVE_FLASH
        application/x-shockwave-flash
      • APPLICATION_X_TAR

        public static final ResourceType APPLICATION_X_TAR
        application/x-tar
      • IMAGE_TIFF

        public static final ResourceType IMAGE_TIFF
        image/tiff
      • APPLICATION_TYPESCRIPT

        public static final ResourceType APPLICATION_TYPESCRIPT
        application/typescript
      • FONT_TTF

        public static final ResourceType FONT_TTF
        font/ttf
      • APPLICATION_VND_VISIO

        public static final ResourceType APPLICATION_VND_VISIO
        application/vnd-visio
      • AUDIO_X_WAV

        public static final ResourceType AUDIO_X_WAV
        audio/x-wav
      • AUDIO_WEBM

        public static final ResourceType AUDIO_WEBM
        audio/webm
      • VIDEO_WEBM

        public static final ResourceType VIDEO_WEBM
        video/webm
      • IMAGE_AVIF

        public static final ResourceType IMAGE_AVIF
        image/avif
      • IMAGE_WEBP

        public static final ResourceType IMAGE_WEBP
        image/webp
      • FONT_WOFF

        public static final ResourceType FONT_WOFF
        font/woff
      • FONT_WOFF2

        public static final ResourceType FONT_WOFF2
        font/woff2
      • APPLICATION_XHTML_XML

        public static final ResourceType APPLICATION_XHTML_XML
        application/xhtml-xml
      • APPLICATION_VND_MS_EXCEL

        public static final ResourceType APPLICATION_VND_MS_EXCEL
        application/vnd-ms-excel
      • APPLICATION_XML

        public static final ResourceType APPLICATION_XML
        application/xml
      • APPLICATION_VND_MOZILLA_XUL_XML

        public static final ResourceType APPLICATION_VND_MOZILLA_XUL_XML
        application/vnd-mozilla-xul-xml
      • APPLICATION_ZIP

        public static final ResourceType APPLICATION_ZIP
        application/zip
      • VIDEO_3GPP

        public static final ResourceType VIDEO_3GPP
        video/3gpp
      • VIDEO_3GPP2

        public static final ResourceType VIDEO_3GPP2
        video/3gpp2
      • APPLICATION_X_7Z_COMPRESSED

        public static final ResourceType APPLICATION_X_7Z_COMPRESSED
        application/x-7z-compressed
    • Constructor Detail

      • ResourceType

        public ResourceType​(java.lang.CharSequence mimeType,
                            Headers headers,
                            boolean gzip,
                            java.util.List<java.lang.String> extensions)
        Creates a new resource type. This is only required if you want to support resource types not included in DEFAULT_EXTENSION_MAPPINGS
        Parameters:
        mimeType - The mime type
        headers - The headers to respond with
        gzip - Whether or not to gzip when serving
        extensions - The file extensions for this resource
    • Method Detail

      • mimeType

        public java.lang.CharSequence mimeType()
        Returns:
        The mime type of this resource, such as image/jpeg
      • headers

        public Headers headers()
        Returns:
        The response headers that mu-server will send when serving this resource type
      • extensions

        public java.util.List<java.lang.String> extensions()
        Returns:
        The file name extensions that this resource type is associated with, for example jpg and jpeg
      • gzip

        public boolean gzip()
        Returns:
        True if by default mu-server gzips this resource type when serving it. (In general text-based resources are gzipped; others aren't.)
      • shortCache

        public static Headers shortCache()
        Returns:
        Creates and returns a Headers object with a single cache-control header set for 5 minutes.
      • noCache

        public static Headers noCache()
        Returns:
        Creates and returns a Headers object with a single cache-control header set with no-cache.
      • getDefaultMapping

        public static java.util.HashMap<java.lang.String,​ResourceType> getDefaultMapping()
        Can be used as a base to customise mime types via ResourceHandlerBuilder.withExtensionToResourceType(Map)
        Returns:
        Returns the built-in mapping of file extension to resource type that can be added to in order to customise resource types.
      • gzippableMimeTypes

        public static java.util.Set<java.lang.String> gzippableMimeTypes​(java.util.Collection<ResourceType> resourceTypes)
        Given a list of resources, returns the ones that are gzippable
        Parameters:
        resourceTypes - Types to check
        Returns:
        The types that have gzip() returning true
      • getResourceTypes

        public static java.util.List<ResourceType> getResourceTypes()
        Returns:
        All the resource types defined by mu-server
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object