httputil

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package httputil implements common HTTP functionality used throughout the Clair codebase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientAddr

func GetClientAddr(r *http.Request) string

GetClientAddr returns the first value in X-Forwarded-For if it exists otherwise fall back to use RemoteAddr

func GetWithContext

func GetWithContext(ctx context.Context, uri string, headers http.Header) (io.ReadCloser, error)

GetWithContext do HTTP GET to the URI with headers and returns response blob reader.

func GetWithUserAgent

func GetWithUserAgent(url string) (*http.Response, error)

GetWithUserAgent performs an HTTP GET with the proper Clair User-Agent.

func PostWithUserAgent

func PostWithUserAgent(url string, data interface{}) (*http.Response, error)

PostWithUserAgent performs an HTTP POST with the proper Clair User-Agent.

func Status2xx

func Status2xx(resp *http.Response) bool

Status2xx returns true if the response's status code is success (2xx)

Types

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is a function used to wrap the logic of another http.Handler.

Jump to

Keyboard shortcuts

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