chowder

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeaderAuth

func HeaderAuth(users map[string]string, handler http.Handler) http.HandlerFunc

HeaderAuth enforces that users are authenticated by reading the Authorization header

func LogRequests

func LogRequests(l zerolog.Logger, handler http.Handler) http.HandlerFunc

LogRequests logs all requests that pass through with loglevel dependant on status code

Types

type ClamAV

type ClamAV struct {
	// contains filtered or unexported fields
}

ClamAV is a virus scanning service backed by a ClamAV tcp connection

func (*ClamAV) Ok

func (av *ClamAV) Ok() (bool, string, error)

Ok checks that the backing ClamAV Antivirus is healthy

func (*ClamAV) Scan

func (av *ClamAV) Scan(stream io.Reader) (bool, string, error)

Scan streams the supplied io.Reader to the backing ClamAV Antivirus

type Proxy

type Proxy struct {
	AntiVirus VirusScanner
}

Proxy is a http proxy for a VirusScanner

func (*Proxy) Ok

Ok returns a response to a healthz request

func (*Proxy) Scan

Scan performs an scan on the body of the request

type Response

type Response struct {
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
}

Response is a baseline response

type ScanResponse

type ScanResponse struct {
	Infected bool `json:"infected"`
	Response `json:",omitempty"`
}

ScanResponse is a response with the result of a scan

type StatusWriter

type StatusWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

StatusWriter wraps a responsewriter to track the status and content length from https://www.reddit.com/r/golang/comments/7p35s4/how_do_i_get_the_response_status_for_my_middleware/

func (*StatusWriter) Write

func (w *StatusWriter) Write(b []byte) (int, error)

Write writes to the changes the underlying ResponseWriter

func (*StatusWriter) WriteHeader

func (w *StatusWriter) WriteHeader(status int)

WriteHeader changes the underlying ResponseWriter header status

type VirusScanner

type VirusScanner interface {
	Scan(stream io.Reader) (infected bool, msg string, err error)
	Ok() (ok bool, msg string, err error)
}

VirusScanner is the interface for a virus scanning service

func NewClamAV

func NewClamAV(connectionString string) VirusScanner

NewClamAV returns a new ClamAV tcp backed VirusScanner

Jump to

Keyboard shortcuts

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