controllers

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentTypeApplicationJSON represent the applcation/json Content-Type value
	ContentTypeApplicationJSON = "application/json"
)

Variables

View Source
var (
	ErrFormFile        = errors.New("failed to parse file")
	ErrOpenFileHeaders = errors.New("failed to open multipart file headers")
)
View Source
var ErrParsingStats = errors.New("error while parsing 'stats'")

Functions

func MaxReqSize added in v0.2.2

func MaxReqSize(maxReqSize int64) func(next http.Handler) http.Handler

MaxReqSizeis a HTTP middleware limiting the size of the request by using http.MaxBytesReader() on the request body.

func SetErrorResponse

func SetErrorResponse(w http.ResponseWriter, err error)

SetErrorResponse will attempt to parse the given error and set the response status code and using the ResponseWriter according to the type of the error.

Types

type ErrorResponse

type ErrorResponse struct {
	Status string `json:"status"`
	Msg    string `json:"msg"`
}

ErrorResponse represents the json response for http errors

func NewErrorResponse

func NewErrorResponse(msg string) *ErrorResponse

type Handler

type Handler struct {
	Clamav clamav.Clamaver
	Logger *zerolog.Logger
}

func NewHandler

func NewHandler(logger *zerolog.Logger, clamav clamav.Clamaver) *Handler

func (*Handler) InStream

func (h *Handler) InStream(w http.ResponseWriter, r *http.Request)

func (*Handler) Ping

func (h *Handler) Ping(w http.ResponseWriter, r *http.Request)

func (*Handler) Reload

func (h *Handler) Reload(w http.ResponseWriter, r *http.Request)

func (*Handler) Shutdown

func (h *Handler) Shutdown(w http.ResponseWriter, r *http.Request)

func (*Handler) Stats

func (h *Handler) Stats(w http.ResponseWriter, r *http.Request)

func (*Handler) Version

func (h *Handler) Version(w http.ResponseWriter, r *http.Request)

func (*Handler) VersionCommands

func (h *Handler) VersionCommands(w http.ResponseWriter, r *http.Request)

type InStreamResponse

type InStreamResponse struct {
	Status     string `json:"status"`
	Msg        string `json:"msg"`
	Signature  string `json:"signature"`
	VirusFound bool   `json:"virus_found"`
}

InStreamResponse represents the json response of a /scan endpoint.

type PingResponse

type PingResponse struct {
	Ping string `json:"ping"`
}

PingResponse represents the json response of a /ping endpoint

type ReloadResponse

type ReloadResponse struct {
	Status string `json:"status"`
}

ReloadResponse represents the json response of a /reload endpoint.

type ShutdownResponse

type ShutdownResponse struct {
	Status string `json:"status"`
}

ShutdownResponse represents the json response of a /shutdown endpoint.

type StatsResponse

type StatsResponse struct {
	Pools    int    `json:"pools"`
	State    string `json:"state"`
	Threads  string `json:"threads"`
	Queue    string `json:"queue"`
	Memstats string `json:"memstats"`
}

StatsResponse represents the json response of a /stats endpoint. It represents the statistics about the scan queue, contents of scan queue, and memory usage.

type VersionCommandsResponse

type VersionCommandsResponse struct {
	Version  string   `json:"clamav_version"`
	Commands []string `json:"commands"`
}

VersionCommandsResponse represents the json response of a /versioncommands endpoint. It represents the version of Clamav, followed by "| COMMANDS:" and a space-delimited list of supported commands.

type VersionResponse

type VersionResponse struct {
	Version string `json:"clamav_version"`
}

VersionResponse represents the json response of a /version endpoint.

Jump to

Keyboard shortcuts

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