// Type defines middleware for checking the request content type.
436758
func Type(opts ...*TypeOpts) fibre.MiddlewareFunc {
	return func(h fibre.HandlerFunc) fibre.HandlerFunc {
		return func(c *fibre.Context) error {

			var config *TypeOpts

			switch len(opts) {
			case 0:
				return h(c)
			default:
				config = opts[0]
			}

			// This is a socket
			if c.IsSocket() {
				return h(c)
			}

			// No config has been set
			if len(config.AllowedContent) == 0 {
				return h(c)
			}

			// Content type is within allowed types
			if _, ok := config.AllowedContent[c.Type()]; ok {
				return h(c)
			}

			return fibre.NewHTTPError(415)

		}
	}
}
67979
func (e *Env) Type(k string) (reflect.Type, error) {
	e.RLock()
	defer e.RUnlock()

	if v, ok := e.typ[k]; ok {
		return v, nil
	}
	if e.external != nil {
		v, err := e.external.Type(k)
		if err == nil {
			return v, nil
		}
	}
	if e.parent == nil {
		if v, ok := basicTypes[k]; ok {
			return v, nil
		}
		return nilType, fmt.Errorf("undefined type '%s'", k)
	}
	return e.parent.Type(k)
}
437230
func (s *ScriptSort) Type(typ string) *ScriptSort {
	s.typ = typ
	return s
}
362384
func (q *QueryStringQuery) Type(typ string) *QueryStringQuery {
	q.typ = typ
	return q
}
847201
func Type(kind string) *Mux {
	return Match(func(ctx *c.Context) bool {
		if ctx.GetString("$phase") != "response" {
			return false
		}
		if value, ok := types.Types[kind]; ok {
			kind = value
		}
		return strings.Contains(ctx.Response.Header.Get("Content-Type"), kind)
	})
}
259663
func (d *driver) Type(ctx types.Context) (types.StorageType, error) {
	return types.Object, nil
}
411293
func (t *TermsLookup) Type(typ string) *TermsLookup {
	t.typ = typ
	return t
}
1249081
func (c *asyncClient) Type(arg0 string) (result FutureKeyType, err Error) {
	arg0bytes := []byte(arg0)

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&TYPE, [][]byte{arg0bytes})
	if err == nil {
		result = newFutureKeyType(resp.future.(FutureString))
	}
	return result, err
}
1345888
func (id ID) Type() Type {
	t, err := id.SafeType()
	if err != nil {
		panic(err)
	}
	return t
}
382334
func (bj BinaryJSON) Type() string {
	switch bj.TypeCode {
	case TypeCodeObject:
		return "OBJECT"
	case TypeCodeArray:
		return "ARRAY"
	case TypeCodeLiteral:
		switch bj.Value[0] {
		case LiteralNil:
			return "NULL"
		default:
			return "BOOLEAN"
		}
	case TypeCodeInt64:
		return "INTEGER"
	case TypeCodeUint64:
		return "UNSIGNED INTEGER"
	case TypeCodeFloat64:
		return "DOUBLE"
	case TypeCodeString:
		return "STRING"
	default:
		msg := fmt.Sprintf(unknownTypeCodeErrorMsg, bj.TypeCode)
		panic(msg)
	}
}
451151
func ContentType(headers http.Header) (string, string, error) {
	ct := headers.Get(HeaderContentType)
	orig := ct
	if ct == "" {
		ct = DefaultMime
	}
	if ct == "" {
		return "", "", nil
	}

	mt, opts, err := mime.ParseMediaType(ct)
	if err != nil {
		return "", "", errors.NewParseError(HeaderContentType, "header", orig, err)
	}

	if cs, ok := opts[charsetKey]; ok {
		return mt, cs, nil
	}

	return mt, "", nil
}
616101
func (f *FilterOp) Type(fieldType string) *FilterOp {
	f.TypeProp = &TypeFilter{Value: fieldType}
	return f
}
766007
func (s *Subscription) Type() SubscriptionType {
	if s == nil {
		return NilSubscription
	}
	s.mu.Lock()
	defer s.mu.Unlock()
	return s.typ
}
736110
func (s *CountService) Type(typ ...string) *CountService {
	if s.typ == nil {
		s.typ = make([]string, 0)
	}
	s.typ = append(s.typ, typ...)
	return s
}
781514
func (bi *BinaryInfo) Type(offset dwarf.Offset) (godwarf.Type, error) {
	return godwarf.ReadType(bi.dwarf, offset, bi.typeCache)
}
165311
func (r *RotateRequest) Types() []services.CertAuthType {
	switch r.Type {
	case "":
		return []services.CertAuthType{services.HostCA, services.UserCA}
	case services.HostCA:
		return []services.CertAuthType{services.HostCA}
	case services.UserCA:
		return []services.CertAuthType{services.UserCA}
	}
	return nil
}
280281
func (s *IndicesStatsService) Type(types ...string) *IndicesStatsService {
	s.types = append(s.types, types...)
	return s
}