package utils
import "github.com/gravitational/oxy/utils"
Index ¶
- Constants
- func CopyHeaders(dst, src http.Header)
- func CopyURL(i *url.URL) *url.URL
- func HasHeaders(names []string, headers http.Header) bool
- func NopWriteCloser(w io.Writer) io.WriteCloser
- func RemoveHeaders(headers http.Header, names ...string)
- type BasicAuth
- type BufferWriter
- func NewBufferWriter(w io.WriteCloser) *BufferWriter
- func (b *BufferWriter) Close() error
- func (b *BufferWriter) Header() http.Header
- func (b *BufferWriter) Write(buf []byte) (int, error)
- func (b *BufferWriter) WriteHeader(code int)
- type ErrorHandler
- type ErrorHandlerFunc
- type ExtractSource
- type ExtractorFunc
- type FileLogger
- func NewFileLogger(w io.Writer, lvl LogLevel) *FileLogger
- func (f *FileLogger) Errorf(format string, args ...interface{})
- func (f *FileLogger) Infof(format string, args ...interface{})
- func (f *FileLogger) Warningf(format string, args ...interface{})
- type LogLevel
- type Logger
- type NOPLogger
- func (*NOPLogger) Error(string)
- func (*NOPLogger) Errorf(format string, args ...interface{})
- func (*NOPLogger) Info(string)
- func (*NOPLogger) Infof(format string, args ...interface{})
- func (*NOPLogger) Warning(string)
- func (*NOPLogger) Warningf(format string, args ...interface{})
- type ProxyWriter
- func (p *ProxyWriter) Flush()
- func (p *ProxyWriter) Header() http.Header
- func (p *ProxyWriter) StatusCode() int
- func (p *ProxyWriter) Write(buf []byte) (int, error)
- func (p *ProxyWriter) WriteHeader(code int)
- type SourceExtractor
- type StdHandler
Constants ¶
const ( INFO = iota WARN ERROR )
Functions ¶
func CopyHeaders ¶
CopyHeaders copies http headers from source to destination, it does not overide, but adds multiple headers
func CopyURL ¶
CopyURL provides update safe copy by avoiding shallow copying User field
func HasHeaders ¶
HasHeaders determines whether any of the header names is present in the http headers
func NopWriteCloser ¶
func NopWriteCloser(w io.Writer) io.WriteCloser
NopCloser returns a WriteCloser with a no-op Close method wrapping the provided Writer w.
func RemoveHeaders ¶
RemoveHeaders removes the header with the given names from the headers map
Types ¶
type BasicAuth ¶
func ParseAuthHeader ¶
func (*BasicAuth) String ¶
type BufferWriter ¶
type BufferWriter struct { H http.Header Code int W io.WriteCloser }
func NewBufferWriter ¶
func NewBufferWriter(w io.WriteCloser) *BufferWriter
func (*BufferWriter) Close ¶
func (b *BufferWriter) Close() error
func (*BufferWriter) Header ¶
func (b *BufferWriter) Header() http.Header
func (*BufferWriter) Write ¶
func (b *BufferWriter) Write(buf []byte) (int, error)
func (*BufferWriter) WriteHeader ¶
func (b *BufferWriter) WriteHeader(code int)
WriteHeader sets rw.Code.
type ErrorHandler ¶
type ErrorHandler interface { ServeHTTP(w http.ResponseWriter, req *http.Request, err error) }
var DefaultHandler ErrorHandler = &StdHandler{}
type ErrorHandlerFunc ¶
type ErrorHandlerFunc func(http.ResponseWriter, *http.Request, error)
func (ErrorHandlerFunc) ServeHTTP ¶
func (f ErrorHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, err error)
ServeHTTP calls f(w, r).
type ExtractSource ¶
type ExtractorFunc ¶
func (ExtractorFunc) Extract ¶
type FileLogger ¶
type FileLogger struct {
// contains filtered or unexported fields
}
func NewFileLogger ¶
func NewFileLogger(w io.Writer, lvl LogLevel) *FileLogger
func (*FileLogger) Errorf ¶
func (f *FileLogger) Errorf(format string, args ...interface{})
func (*FileLogger) Infof ¶
func (f *FileLogger) Infof(format string, args ...interface{})
func (*FileLogger) Warningf ¶
func (f *FileLogger) Warningf(format string, args ...interface{})
type LogLevel ¶
type LogLevel int
type Logger ¶
type Logger interface { Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) }
Logger defines a simple logging interface
type NOPLogger ¶
type NOPLogger struct { }
func (*NOPLogger) Error ¶
func (*NOPLogger) Errorf ¶
func (*NOPLogger) Info ¶
func (*NOPLogger) Infof ¶
func (*NOPLogger) Warning ¶
func (*NOPLogger) Warningf ¶
type ProxyWriter ¶
type ProxyWriter struct { W http.ResponseWriter Code int }
ProxyWriter helps to capture response headers and status code from the ServeHTTP. It can be safely passed to ServeHTTP handler, wrapping the real response writer.
func (*ProxyWriter) Flush ¶
func (p *ProxyWriter) Flush()
func (*ProxyWriter) Header ¶
func (p *ProxyWriter) Header() http.Header
func (*ProxyWriter) StatusCode ¶
func (p *ProxyWriter) StatusCode() int
func (*ProxyWriter) Write ¶
func (p *ProxyWriter) Write(buf []byte) (int, error)
func (*ProxyWriter) WriteHeader ¶
func (p *ProxyWriter) WriteHeader(code int)
type SourceExtractor ¶
type SourceExtractor interface { Extract(req *http.Request) (token string, amount int64, err error) }
ExtractSource extracts the source from the request, e.g. that may be client ip, or particular header that identifies the source. amount stands for amount of connections the source consumes, usually 1 for connection limiters error should be returned when source can not be identified
func NewExtractor ¶
func NewExtractor(variable string) (SourceExtractor, error)
type StdHandler ¶
type StdHandler struct { }
func (*StdHandler) ServeHTTP ¶
func (e *StdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request, err error)
Source Files ¶
auth.go handler.go logging.go netutils.go source.go
- Version
- v0.0.0-20231219172753-f855322f2a6c (latest)
- Published
- Dec 19, 2023
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 5 months ago –
Tools for package owners.