mimetools

package
v0.0.0-...-3fff119 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2015 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package mimetools provides functions for matching against media types

Also referred to ad MIME types, see http://en.wikipedia.org/wiki/Internet_media_type

It primarily exports Matcher:

mm := mimetools.NewMatcher([]string{"text/*", "application/json"})
mm.Match("text/html") // returns true, nil
mm.Match("text/plain") //returns true, nil
mm.Match("application/json") // returns true, nil
mm.Match("application/vnd.ms-excel") // returns false, nil

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher will match Accept or Content-Type mime types that include *

func NewMatcher

func NewMatcher(mediaTypes []string) (*Matcher, error)

NewMatcher returns a new matcher instance and any errors that occurred. Note that if an error is returned, a Matcher is returned that matches any mime type.

func (*Matcher) Match

func (mm *Matcher) Match(mimeString string) (bool, error)

Match returns true if mimeString matches, false otherwise.

Jump to

Keyboard shortcuts

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