jsonrouter

package
v0.0.0-...-1676a5e Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastHttpRouter

type FastHttpRouter func(ctx *fasthttp.RequestCtx)

func New

func New(serviceName string, logger logging.Logger, spec interface{}) (*tree.Node, FastHttpRouter)

New creates a JSONrouter for the fasthttp platform.

func (FastHttpRouter) Serve

func (router FastHttpRouter) Serve(port int, maxRequestBodySize ...int) error

Serve is a function which calls the ListenAndServe func in the fasthttp package.

func (FastHttpRouter) ServeTLS

func (router FastHttpRouter) ServeTLS(port int, crt, key string, maxRequestBodySize ...int) error

Serve is a function which calls the ListenAndServeTLS func in the fasthttp package.

type Request

type Request struct {
	*parameters.Parameters

	Node *tree.Node

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRequestObject

func NewRequestObject(node *tree.Node, ctx *fasthttp.RequestCtx) *Request

NewRequestObject constructs a new Request implementation for the fasthttp latform.

func (*Request) Body

func (req *Request) Body(k string) interface{}

Body gets a field out of the map created from the body JSON.

func (*Request) BodyArray

func (req *Request) BodyArray() []interface{}

BodyArray returns the HTTP body which was previously unmarshaled into a slice.

func (*Request) BodyObject

func (req *Request) BodyObject() map[string]interface{}

BodyObject returns the HTTP body which was previously unmarshaled into a map.

func (*Request) Debug

func (req *Request) Debug(msg string)

func (*Request) DebugJSON

func (req *Request) DebugJSON(i interface{})

func (*Request) Device

func (req *Request) Device() string

Device returns the device object.

func (*Request) Error

func (req *Request) Error(msg error)

func (*Request) Fail

func (req *Request) Fail() *http.Status

Fail sends HTTP 500 status error.

func (*Request) FullPath

func (req *Request) FullPath() string

FullPath returns the path for the http request.

func (*Request) GetRequestHeader

func (req *Request) GetRequestHeader(k string) string

GetRequestHeader sets a request header value.

func (*Request) GetResponseHeader

func (req *Request) GetResponseHeader(k string) string

GetResponseHeader gets a header value from the response.

func (*Request) HttpError

func (req *Request) HttpError(msg string, code int)

Respond calls the respond method which creates the response payload.

func (*Request) IsTLS

func (req *Request) IsTLS() bool

IsTLS returns the state of whether this request is a secure request.

func (*Request) Log

func (req *Request) Log() logging.Logger

Log returns the logging client.

func (*Request) Method

func (req *Request) Method() string

Method returns the HTTP method of the request, e.g. POST, GET, PUT etc

func (*Request) NewError

func (req *Request) NewError(msg string) error

func (*Request) R

func (req *Request) R() interface{}

Does nothing useful in httprouter

func (*Request) RawBody

func (req *Request) RawBody() (*http.Status, []byte)

RawBody returns the HTTP request body.

func (*Request) ReadBodyArray

func (req *Request) ReadBodyArray() *http.Status

ReadBodyArray unmarshals the body into a slice of interface{}.

func (*Request) ReadBodyObject

func (req *Request) ReadBodyObject() *http.Status

ReadBodyObject unmarshals the body into a map of interface{}.

func (*Request) Redirect

func (req *Request) Redirect(path string, code int) *http.Status

Redirect redirects the http to the destination URL.

func (*Request) Reflect

func (req *Request) Reflect(e interface{})

func (*Request) Res

func (req *Request) Res() www.ResponseWriter

Does nothing useful in httprouter

func (*Request) Respond

func (req *Request) Respond(args ...interface{}) *http.Status

Redirect redirects the http to the destination URL.

func (*Request) ServeFile

func (req *Request) ServeFile(path string)

ServeFile serves the file from the path specified.

func (*Request) SetBodyArray

func (self *Request) SetBodyArray(array []interface{})

SetBodyArray

func (*Request) SetBodyObject

func (self *Request) SetBodyObject(obj map[string]interface{})

SetBodyObject

func (*Request) SetRequestHeader

func (req *Request) SetRequestHeader(k, v string)

SetRequestHeader sets a request header value.

func (*Request) SetResponseHeader

func (req *Request) SetResponseHeader(k, v string)

SetResponseHeader sets a response header value.

func (*Request) Testing

func (req *Request) Testing() bool

Testing returns whether or not this is a test implementation.

func (*Request) Write

func (req *Request) Write(b []byte) (int, error)

Write calls the write method on the 'core/http' responsewriter

func (*Request) WriteString

func (req *Request) WriteString(s string) (int, error)

WriteString calls the write method on the 'core/http' responsewriter after transforming the input to a byte slice.

func (*Request) Writer

func (req *Request) Writer() io.Writer

Writer returns the responseWriter as an io.Writer.

Jump to

Keyboard shortcuts

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