compressible

package module
v0.0.0-...-6b91385 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2016 License: MIT Imports: 3 Imported by: 1

README

compressible

Build Status Coverage Status

MIME compressible checking for Go

Installation

go get -u github.com/go-http-utils/compressible

Documentation

API documentation can be found here: https://godoc.org/github.com/go-http-utils/compressible

Usage

import (
  _ "github.com/GitbookIO/mimedb/autoload"
  "github.com/go-http-utils/compressible"
)
fmt.Println(compressible.Test("text/html"))
// -> true

fmt.Println(compressible.Test("image/jpeg"))
// -> false

Documentation

Overview

Package compressible provides MIME compressible checking for Go

Index

Examples

Constants

View Source
const Version = "0.3.0"

Version is this package's version

Variables

This section is empty.

Functions

func Test

func Test(contentType string) bool

Test checks whether the given contentType is compressible, using https://github.com/GitbookIO/mimedb as mime database.Recommand to autoload all extensions and their associated content type by `import _ "github.com/GitbookIO/mimedb/autoload"` first. All types that not in mimedb but have the scheme of "text/*", "*/*+json", "*/*+text" and "*/*+xml" are considered as compressible.

Example
package main

import (
	"fmt"

	_ "github.com/GitbookIO/mimedb/autoload"
	"github.com/go-http-utils/compressible"
)

func main() {
	fmt.Println(compressible.Test("text/html"))
	// -> true

	fmt.Println(compressible.Test("image/png"))
	// -> false
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL