serverutil

package
v1.13.1-0...-fbee82e Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSpambot = errors.New("request looks like spam")
)

Functions

func DeleteCookie

func DeleteCookie(writer http.ResponseWriter, request *http.Request, cookieName string) bool

DeleteCookie deletes the given cookie if it exists. It returns true if it exists and false with no errors if it doesn't

func InitMinifier

func InitMinifier()

InitMinifier sets up the HTML/JS/JSON minifier if enabled in gochan.json

func IsRequestingJSON

func IsRequestingJSON(request *http.Request) bool

func MinifyTemplate

func MinifyTemplate[T templateRef](tmplRef T, data any, writer io.Writer, mediaType string) (err error)

MinifyTemplate minifies the given template ref (string or template.Template pointer) and data, and returns any errors

func MinifyWriter

func MinifyWriter(writer io.Writer, data []byte, mediaType string) (int, error)

MinifyWriter minifies the given writer/data (if enabled) and returns the number of bytes written and any errors

func PreloadModule

func PreloadModule(l *lua.LState) int

Types

type RefererResult

type RefererResult int
const (
	// NoReferer is returned when the request has no referer
	NoReferer RefererResult = iota
	// InvalidReferer is returned when the referer not a valid URL
	InvalidReferer
	// InternalReferer is returned when the request came from the same site as the server
	InternalReferer
	// ExternalReferer is returned when the request came from another site. It may or may not be be spam, depending on the context
	ExternalReferer
)

func CheckReferer

func CheckReferer(request *http.Request) (RefererResult, error)

CheckReferer checks to make sure that the incoming request is from the same domain

Jump to

Keyboard shortcuts

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