interceptor

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package interceptor exports a interfaces that defines a interceptor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interceptor

type Interceptor interface {

	// Rules returns a list of interceptor.InterceptorRuler with the functions that it will validate
	// if the content must be modify or not.
	Rules() []InterceptorRuler

	// Handler returns a [interceptor.InterceptorHandler] with all operations to modify a content requested.
	Handler() InterceptorHandler
}

Interceptor exposes two methods to handle the modification that must be apply to the content requested.

type InterceptorHandler

type InterceptorHandler func(*http.Response) error

InterceptorHandler defines a function that execution the injection.

Receives an *http.Response with the request content to modify.

type InterceptorRuler

type InterceptorRuler func(*http.Response) bool

InterceptorRuler defines a function that contains the rules to determine if a request must be injected or not.

Receives an *http.Response with the requested content to be evaluated by the rule. Returns true if a request pass the rule, otherwise must be return false.

Directories

Path Synopsis
Package liverreload injects in a html page requested a snippet from a filepath to handle a livereload system in client side.
Package liverreload injects in a html page requested a snippet from a filepath to handle a livereload system in client side.

Jump to

Keyboard shortcuts

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