mime

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mime defines commonly used mime types in Jenny

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

type Type string

Type repreents a mimeType

const (
	// TextPlain default mimeType for a lot of things
	TextPlain Type = "text/plain"
	// ApplicationJSON application/json type
	ApplicationJSON Type = "application/json"
	// ApplicationXML application/xml type
	ApplicationXML Type = "application/xml"
	// ApplicationOctet application/octet-stream type, for generic stuff
	ApplicationOctet Type = "application/octet-stream"
	// ApplicationFormURLEncoded for form encoded stuff
	ApplicationFormURLEncoded Type = "application/x-www-form-urlencoded"
)

func (Type) Group

func (t Type) Group() string

func (Type) SubGroup

func (t Type) SubGroup() string

type Types

type Types map[string]map[string]float64

Types represents a collection of mimeTypes

func Aggregate

func Aggregate(list []Type) Types

Aggregate takes a array of mime.Type as strings and builds a mime.Types from it elements of the array have to be in <type>/<subType> format. Weights are not supported.

func Intersect

func Intersect(a Types, b Types) Types

Intersect takes two mime.Types and returns the intersection of two Types'

 'A' and 'B' and writes each element thats present in both Typess to a new
 Types. In the result grpah, weights of the node are derived from Types 'B'

  text/html, text/plain;q=0.9          text/troff, text/html;q=0.9
	+-TypesA--------------------+        +-TypesB--------------------+
	|            text           |        |              text         |
	|              +            |        |               +           |
	|              |            |        |               |           |
	| plain <------+----> html  |        | html <--------+---> troff |
	|   +                   +   |        |  +                   +    |
	|   |                   |   |        |  |                   |    |
	|   |                   |   |        |  |                   |    |
	|   v                   v   |        |  v                   v    |
	| 0.9                   1.0 |        | 0.9                  1.0  |
	+---------------------------+        +---------------------------+

	+-result----------------+
	|       text            |
	|        +              |
	|        |              |
	|        v              |
	|       html            |
 |        +              |
	|        |              |
	|        v              |
	|       0.9             |
	+-----------------------+

func NewTypes

func NewTypes(s string) Types

NewTypes takes a string, possibly one from a header and builds a grpah from it.

func RequestTypes

func RequestTypes(r *http.Request) Types

RequestTypes takes a http.Request and builds a mimeTypes from it.

func (Types) Walk

func (t Types) Walk(wf WalkFunc) error

Walk helps you iterate trough mime.Types in a collection

type WalkFunc

type WalkFunc func(Type) error

WalkFunc is used for iterating trough mime.Types

Jump to

Keyboard shortcuts

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