router

package
v0.0.0-...-33a0e38 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package router defines some interfaces for router adapters

Index

Constants

View Source
const (
	HeaderCompleteResponseValue   = "true"
	HeaderIncompleteResponseValue = "false"
)

Variables

View Source
var (
	// CompleteResponseHeaderName is the header to flag incomplete responses to the client
	CompleteResponseHeaderName = "X-KrakenD-Completed"
	// HeadersToSend are the headers to pass from the router request to the proxy
	HeadersToSend = []string{"Content-Type"}
	// UserAgentHeaderValue is the value of the User-Agent header to add to the proxy request
	UserAgentHeaderValue = []string{core.KrakendUserAgent}
	// ErrInternalError is the error returned by the router when something went wrong
	ErrInternalError = errors.New("internal server error")
)

Functions

func DefaultToHTTPError

func DefaultToHTTPError(_ error) int

DefaultToHTTPError is a ToHTTPError transalator that always returns an internal server error

func InitHTTPDefaultTransport

func InitHTTPDefaultTransport(cfg config.ServiceConfig)

InitHTTPDefaultTransport ensures the default HTTP transport is configured just once per execution

Types

type Factory

type Factory interface {
	New() Router
	NewWithContext(context.Context) Router
}

Factory creates new routers

type Router

type Router interface {
	Run(config.ServiceConfig)
}

Router sets up the public layer exposed to the users

type RouterFunc

type RouterFunc func(config.ServiceConfig)

RouterFunc type is an adapter to allow the use of ordinary functions as routers. If f is a function with the appropriate signature, RouterFunc(f) is a Router that calls f.

func (RouterFunc) Run

func (f RouterFunc) Run(cfg config.ServiceConfig)

Run implements the Router interface

type ToHTTPError

type ToHTTPError func(error) int

ToHTTPError translates an error into a HTTP status code

Directories

Path Synopsis
Package gin provides some basic implementations for building routers based on gin-gonic/gin
Package gin provides some basic implementations for building routers based on gin-gonic/gin
Package mux provides some basic implementations for building routers based on net/http mux Package mux provides some basic implementations for building routers based on net/http mux
Package mux provides some basic implementations for building routers based on net/http mux Package mux provides some basic implementations for building routers based on net/http mux

Jump to

Keyboard shortcuts

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