middleware

package
v0.164.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package middleware define middlewares for Actions.

Index

Constants

View Source
const ExtraPadding = DefaultInitialPadding * 2

ExtraPadding is the double of the DefaultInitialPadding.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(ctx *context.Context) error

Action is a function that takes a context and returns an error. It is is used on Pipers, Defaulters and Publishers, although they are not aware of this generalization.

func ErrHandler

func ErrHandler(action Action) Action

ErrHandler handles an action error, ignoring and logging pipe skipped errors.

func Logging

func Logging(title string, next Action, padding Padding) Action

Logging pretty prints the given action and its title. You can have different padding levels by providing different initial paddings. The middleware will print the title in the given padding and the action logs in padding+default padding. The default padding in the log library is 3. The middleware always resets to the default padding.

type Padding

type Padding int

Padding is a logging initial padding.

const DefaultInitialPadding Padding = 3

DefaultInitialPadding is the default padding in the log library.

Jump to

Keyboard shortcuts

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