client

package
v0.0.0-...-84d4900 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BodyLimitSize int64 = 1048576

BodyLimitSize is the max request body size.

View Source
var HTTPClient *http.Client

HTTPClient is the http.Client

Functions

func ConfigHTTPClient

func ConfigHTTPClient(certificate, privateKey, ca string, insecure bool) error

ConfigHTTPClient config the http client that is used by do method to access the router.

Types

type Route

type Route struct {
	Router string
}

type Router

type Router struct {
	// Router name that will handle the request.
	Router string
	// URL of the router server. To access the REST service.
	URL *url.URL

	// Addrs of the host that code will be running.
	Addrs string
	// contains filtered or unexported fields
}

Router agregate the methods to interact with the router server and add methods to it.

var DefaultRouter *Router

TODO: Default router client on package level

func (*Router) DELETE

func (r *Router) DELETE(ctx context.Context, path string, handle http.HandlerFunc) error

DELETE route with http method DELETE.

func (*Router) GET

func (r *Router) GET(ctx context.Context, path string, handle http.HandlerFunc) error

GET route with http method GET.

func (*Router) GetRoutes

func (r *Router) GetRoutes(ctx context.Context) (router.Routes, error)

func (*Router) HEAD

func (r *Router) HEAD(ctx context.Context, path string, handle http.HandlerFunc) error

HEAD route with http method HEAD.

func (*Router) HandlerFunc

func (r *Router) HandlerFunc(ctx context.Context, method, path string, handler http.HandlerFunc) error

HandlerFunc is a generic method to add a route into the router.

func (*Router) OPTIONS

func (r *Router) OPTIONS(ctx context.Context, path string, handle http.HandlerFunc) error

OPTIONS route with http method OPTIONS.

func (*Router) PATCH

func (r *Router) PATCH(ctx context.Context, path string, handle http.HandlerFunc) error

PATCH route with http method PATCH.

func (*Router) POST

func (r *Router) POST(ctx context.Context, path string, handle http.HandlerFunc) error

POST route with http method POST.

func (*Router) PUT

func (r *Router) PUT(ctx context.Context, path string, handle http.HandlerFunc) error

PUT route with http method PUT.

func (*Router) PathExist

func (r *Router) PathExist(path string) bool

func (*Router) Paths

func (r *Router) Paths() (paths []string)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP is a http server with the route setup by *Router.

func (*Router) Start

func (r *Router) Start(ctx context.Context) error

Start initialize the router. Setup the server that will receive the income requests and send it to the right route.

Jump to

Keyboard shortcuts

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