helper

package
v6.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const NginxResponseBufferHeader = "X-Accel-Buffering"

Variables

This section is empty.

Functions

func AllowResponseBuffering added in v1.1.0

func AllowResponseBuffering(w http.ResponseWriter)

func CleanHeadersForRaven added in v0.8.3

func CleanHeadersForRaven(r *http.Request)

func CleanUpProcessGroup added in v0.6.1

func CleanUpProcessGroup(cmd *exec.Cmd)

func CloneRequestWithNewBody added in v1.4.0

func CloneRequestWithNewBody(r *http.Request, body []byte) *http.Request

func DisableResponseBuffering added in v1.1.0

func DisableResponseBuffering(w http.ResponseWriter)

func ExitStatus added in v0.6.1

func ExitStatus(err error) (int, bool)

func Fail500

func Fail500(w http.ResponseWriter, r *http.Request, err error)

func HTTPError

func HTTPError(w http.ResponseWriter, r *http.Request, error string, code int)

func HeaderClone added in v0.6.3

func HeaderClone(h http.Header) http.Header

func IsApplicationJson added in v1.4.0

func IsApplicationJson(r *http.Request) bool

func IsContentType added in v1.3.0

func IsContentType(expected, actual string) bool

func LogError

func LogError(r *http.Request, err error)

func NewAccessLogFormatter

func NewAccessLogFormatter() log.Formatter

NewAccessLogFormatter returns a new formatter for combined access logs

func OpenFile

func OpenFile(path string) (file *os.File, fi os.FileInfo, err error)

func ReadAllTempfile added in v1.3.0

func ReadAllTempfile(r io.Reader) (tempfile *os.File, err error)

func ReadRequestBody added in v1.4.0

func ReadRequestBody(w http.ResponseWriter, r *http.Request, maxBodySize int64) ([]byte, error)

func RequestEntityTooLarge added in v1.4.0

func RequestEntityTooLarge(w http.ResponseWriter, r *http.Request, err error)

func ScrubURLParams

func ScrubURLParams(originalURL string) string

Based on https://stackoverflow.com/a/52965552/474597 ScrubURLParams replaces the content of any sensitive query string parameters in an URL with `[FILTERED]`

func SetAccessLoggerEntry

func SetAccessLoggerEntry(logEntry *log.Entry)

SetAccessLoggerEntry sets the access logger used in the system

func SetForwardedFor added in v1.3.0

func SetForwardedFor(newHeaders *http.Header, originalRequest *http.Request)

func SetNoCacheHeaders

func SetNoCacheHeaders(header http.Header)

func URLMustParse

func URLMustParse(s string) *url.URL

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock interface provides the time

type CountingResponseWriter

type CountingResponseWriter interface {
	http.ResponseWriter
	Count() int64
	Status() int
}

func NewCountingResponseWriter

func NewCountingResponseWriter(rw http.ResponseWriter) CountingResponseWriter

type LoggingResponseWriter

type LoggingResponseWriter interface {
	http.ResponseWriter

	RequestFinished(r *http.Request)
}

func NewStatsCollectingResponseWriter

func NewStatsCollectingResponseWriter(rw http.ResponseWriter) LoggingResponseWriter

type RealClock

type RealClock struct{}

RealClock is the default time implementation

func (RealClock) Now

func (RealClock) Now() time.Time

Now returns the time

type StubClock

type StubClock struct {
	StubTime time.Time
}

StubClock is the default time implementation

func (*StubClock) Now

func (c *StubClock) Now() time.Time

Now returns a stub time

type WriteFlusher added in v1.4.0

type WriteFlusher interface {
	io.Writer
	Flush() error
}

func NewWriteAfterReader added in v1.4.0

func NewWriteAfterReader(r io.Reader, w io.Writer) (io.Reader, WriteFlusher)

Couple r and w so that until r has been drained (before r.Read() has returned some error), all writes to w are sent to a tempfile first. The caller must call Flush() on the returned WriteFlusher to ensure all data is propagated to w.

Jump to

Keyboard shortcuts

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