// Wants maps a content-type, or part of one ("json", "html", "form", etc...),
// to a buffalo.Handler to respond with when it gets that content-type, returns a
// Responder that can be used for further mappings.
344881
func Wants(ct string, h buffalo.Handler) Responder {
	r := &Responder{
		moot:  &sync.Mutex{},
		wants: map[string]buffalo.Handler{},
	}
	return r.Wants(ct, h)
}
1054412
func (n *negotiator) ContentType(ctypes ...string) bool {
	return checkCT(n.r.Header.Get("Content-Type"), ctypes...)
}
108227
func (r *Request) MatchType(kind string) *Request {
	mime := BodyTypeAliases[kind]
	if mime != "" {
		kind = mime
	}
	r.Header.Set("Content-Type", kind)
	return r
}
227770
func wantsCompressedResponse(req *http.Request) (bool, string) {
	// don't compress watches
	ctx := req.Context()
	info, ok := request.RequestInfoFrom(ctx)
	if !ok {
		return false, ""
	}
	if !info.IsResourceRequest {
		return false, ""
	}
	if info.Verb == "watch" {
		return false, ""
	}
	header := req.Header.Get(headerAcceptEncoding)
	gi := strings.Index(header, encodingGzip)
	zi := strings.Index(header, encodingDeflate)
	// use in order of appearance
	switch {
	case gi == -1:
		return zi != -1, encodingDeflate
	case zi == -1:
		return gi != -1, encodingGzip
	case gi < zi:
		return true, encodingGzip
	default:
		return true, encodingDeflate
	}
}
1115894
func (r *HelloResource) Get(context smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) {
	resp := HelloResponse{}
	resp.Init(context)

	name := params["name"]
	if len(name) > 0 {
		resp.Reply = "Hello " + name[0]
	}

	resp.Send(response)
}
567829
func (r *OpenRequest) Respond(resp *OpenResponse) {
	buf := newBuffer(unsafe.Sizeof(openOut{}))
	out := (*openOut)(buf.alloc(unsafe.Sizeof(openOut{})))
	out.Fh = uint64(resp.Handle)
	out.OpenFlags = uint32(resp.Flags)
	r.respond(buf)
}
896936
func (r *Response) Get(key string) string {
	return r.handlerHeader.Get(key)
}
77250
func (c *RPCClient) Respond(id uint64, buf []byte) error {
	header := requestHeader{
		Command: respondCommand,
		Seq:     c.getSeq(),
	}
	req := respondRequest{
		ID:      id,
		Payload: buf,
	}
	return c.genericRPC(&header, &req, nil)
}
933949
func getResponse(resp *http.Response, e error) (tumblr.Response, error) {
	response := tumblr.Response{}
	if e != nil {
		return response, e
	}
	defer resp.Body.Close()
	response.Headers = resp.Header
	body, e := ioutil.ReadAll(resp.Body)
	if e != nil {
		return response, e
	}
	response = *tumblr.NewResponse(body, resp.Header)
	if resp.StatusCode < 200 || resp.StatusCode >= 400 {
		return response, errors.New(resp.Status)
	}
	return response, nil
}
560757
func getContentType(request http.Header, proxyResponse http.Header) (headerContentType string) {
	responseHeader := proxyResponse.Get("Content-Type")
	requestHeader := request.Get("Content-Type")

	if len(responseHeader) > 0 {
		headerContentType = responseHeader
	} else if len(requestHeader) > 0 {
		headerContentType = requestHeader
	} else {
		headerContentType = defaultContentType
	}

	return headerContentType
}
1258163
func (rep *Responder) Respond(request *http.Request) {
	// get request format from url
	if ext := filepath.Ext(request.URL.Path); ext != "" {
		if respond, ok := rep.responds[strings.TrimPrefix(ext, ".")]; ok {
			respond()
			return
		}
	}

	// get request format from Accept
	for _, accept := range strings.Split(request.Header.Get("Accept"), ",") {
		if exts, err := mime.ExtensionsByType(accept); err == nil {
			for _, ext := range exts {
				if respond, ok := rep.responds[strings.TrimPrefix(ext, ".")]; ok {
					respond()
					return
				}
			}
		}
	}

	// use first format as default
	if rep.DefaultResponder != nil {
		rep.DefaultResponder()
	}
	return
}
430050
func sendResponse(w http.ResponseWriter, response interface{}, status int) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	marshalledResponse, err := json.Marshal(response)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		w.Write([]byte(fmt.Sprintf("Failed to marshal response: %v %v", response, err)))
		return
	}
	w.WriteHeader(status)
	w.Write(marshalledResponse)
}
1061950
func (c *RawBinaryClient) Get(key string) GetResponse {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	if resp := c.sendGetRequest(key); resp != nil {
		return resp
	}

	return c.receiveGetResponse(key)
}
249121
func Get(r *http.Request) (claims map[string]interface{}, ok bool) {
	c, ok := context.GetOk(r, context_key)
	if !ok {
		return claims, ok
	}
	claims, castOk := c.(map[string]interface{})
	return claims, castOk
}
1124208
func (s *meController) Get() interface{} {
	var handler MeGetHandler = func(log *log.Logger, r render.Render, tokens oauth2.Tokens) {
		userInfo := GetUserInfo(tokens)
		log.Println("getting userInfo: ", userInfo)
		genericResponseFormatter(r, "", userInfo, nil)
	}
	return handler
}
604530
func Get(req *http.Request, metaResult interface{}) (io.ReadCloser, error) {
	ctype := req.Header.Get("Content-Type")
	mediaType, cParams, err := mime.ParseMediaType(ctype)
	if err != nil {
		return nil, errors.Annotate(err, "while parsing content type header")
	}

	if !strings.HasPrefix(mediaType, "multipart/") {
		return nil, errors.Errorf("expected multipart Content-Type, got %q", mediaType)
	}
	reader := multipart.NewReader(req.Body, cParams["boundary"])

	// Extract the metadata.
	part, err := reader.NextPart()
	if err != nil {
		if err == io.EOF {
			return nil, errors.New("missing metadata")
		}
		return nil, errors.Trace(err)
	}

	if err := checkContentType(part.Header, params.ContentTypeJSON); err != nil {
		return nil, errors.Trace(err)
	}
	if err := json.NewDecoder(part).Decode(metaResult); err != nil {
		return nil, errors.Trace(err)
	}

	// Extract the archive.
	part, err = reader.NextPart()
	if err != nil {
		if err == io.EOF {
			return nil, errors.New("missing archive")
		}
		return nil, errors.Trace(err)
	}
	if err := checkContentType(part.Header, params.ContentTypeRaw); err != nil {
		return nil, errors.Trace(err)
	}
	// We're not going to worry about verifying that the file matches the
	// metadata (e.g. size, checksum).
	archive := part

	// We are going to trust that there aren't any more attachments after
	// the file. If there are, we ignore them.

	return archive, nil
}
384963
func (s *HTTPServer) SearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	if req.Method == "POST" || req.Method == "PUT" {
		return s.newSearchRequest(resp, req)
	}
	return nil, CodedError(405, ErrInvalidMethod)
}