engine

package
v0.0.0-...-f87def4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package engine provides a core interface for flotilla routing as well as a default engine flotilla based on https://github.com/julienschmidt/httprouter, in addition to associated functionality managing for routing results across packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanPath

func CleanPath(p string) string

func DefaultEngine

func DefaultEngine(status Rule) *engine

Provided a default status Rule, DefaultEngine returns a default engine instance.

Types

type Engine

type Engine interface {
	Handle(string, string, Rule)
	ServeHTTP(http.ResponseWriter, *http.Request)
}

The Engine interface encapsulates routing management and satisfies the net/http ServeHTTP interface function.

type Param

type Param struct {
	Key   string
	Value string
}

type Params

type Params []Param

func (Params) ByName

func (ps Params) ByName(name string) string

type Recorded

type Recorded struct {
	Start, Stop             time.Time
	Latency                 time.Duration
	Status                  int
	Method, Path, Requester string
}

The Recorded struct holds request & handling data.

type Recorder

type Recorder interface {
	PostProcess(*http.Request, int)
	Record() *Recorded
}

Recorder is an interface for recording request & handling data.

type Result

type Result struct {
	Rule Rule

	TSR bool
	xrr.Xrroror
	Recorder
	// contains filtered or unexported fields
}

Result is a struct for holding information on found routes when handled by an Engine.

func NewResult

func NewResult(code int, rule Rule, params Params, tsr bool) *Result

NewResult provides a Result instance, provided an integer code, a Rule, Params, and a boolean indicating trailing slash redirect.

func (*Result) Code

func (r *Result) Code() int

The Result structure Code function returning an integer.

func (*Result) Params

func (r *Result) Params() Params

the Ressult structure Params function, returning a Params set.

type Resulter

type Resulter interface {
	Code() int
	Params() Params
	Recorder
}

The Resulter interface provides integer code information, Params, and a Recorder where needed.

type Rule

type Rule func(http.ResponseWriter, *http.Request, *Result)

A routing Rule requires a http.ResponseWriter, *http.Request, and a Result instance.

Jump to

Keyboard shortcuts

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