router

package
v0.0.0-...-cd4b7d1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPRouter

type HTTPRouter interface {

	// GET registers a new request handle for HTTP GET method.
	GET(path string, h httprouter.Handle)
	// PUT registers a new request handle for HTTP PUT method.
	PUT(path string, h httprouter.Handle)
	// POST registers a new request handle for HTTP POST method.
	POST(path string, h httprouter.Handle)
	// DELETE registers a new request handle for HTTP DELETE method.
	DELETE(path string, h httprouter.Handle)
	// HEAD registers a new request handle for HTTP HEAD method.
	HEAD(path string, h httprouter.Handle)
	// OPTIONS registers a new request handle for HTTP OPTIONS method.
	OPTIONS(path string, h httprouter.Handle)
	// PATCH registers a new request handle for HTTP PATCH method.
	PATCH(path string, h httprouter.Handle)

	// If enabled, the router automatically replies to OPTIONS requests.
	// Nevertheless OPTIONS handlers take priority over automatic replies.
	// By default this option is enabled
	UseOptionsReplies(bool)

	// SetupNotAllowedHandler defines own handler which is called when a request
	// cannot be routed.
	SetupNotAllowedHandler(http.Handler)

	// SetupNotFoundHandler allows to define own handler for undefined URL path.
	// If it is not set, http.NotFound is used.
	SetupNotFoundHandler(http.Handler)

	// SetupRecoveryHandler allows to define handler that called when panic happen.
	// The handler prevents your server from crashing and should be used to return
	// http status code http.StatusInternalServerError (500)
	// interface{} will contain value which is transmitted from panic call.
	SetupRecoveryHandler(func(http.ResponseWriter, *http.Request, interface{}))

	// Listen and serve on requested host and port e.g "0.0.0.0:8080"
	Listen(hostPort string) error
}

HTTPRouter interface contains base http methods e.g. GET, PUT, POST and defines your own handlers that is useful in some use cases

Source Files

  • httprouter.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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