Documentation
¶
Index ¶
- type BasicRequest
- func (br *BasicRequest) GetBody() io.ReadCloser
- func (br *BasicRequest) GetCookies() []*http.Cookie
- func (br *BasicRequest) GetHeaders() KeyValues
- func (br *BasicRequest) GetMethod() string
- func (br *BasicRequest) GetQueryParameters() KeyValues
- func (br *BasicRequest) GetRequest() *http.Request
- func (br *BasicRequest) GetURL() string
- func (br *BasicRequest) GetURLParameters() KeyValue
- type BasicRoute
- func (br *BasicRoute) Delete(handlers ...Handler) IRoute
- func (br *BasicRoute) Get(handlers ...Handler) IRoute
- func (br *BasicRoute) Match(targetURL string) bool
- func (br *BasicRoute) MultiMethod(methods []string, handlers ...Handler) IRoute
- func (br *BasicRoute) Patch(handlers ...Handler) IRoute
- func (br *BasicRoute) Post(handlers ...Handler) IRoute
- func (br *BasicRoute) Put(handlers ...Handler) IRoute
- type HTTPResponseWriterWrapper
- func (w *HTTPResponseWriterWrapper) Bytes(bytes []byte) IResponse
- func (w *HTTPResponseWriterWrapper) Header(key string, value string) IResponse
- func (w *HTTPResponseWriterWrapper) JSON(data interface{}) IResponse
- func (w *HTTPResponseWriterWrapper) Status(statusCode int) IResponse
- func (w *HTTPResponseWriterWrapper) Text(text string) IResponse
- type Handler
- type IRequest
- type IResponse
- type IRoute
- type KeyValue
- type KeyValues
- type MockRequest
- func (mr *MockRequest) GetBody() io.ReadCloser
- func (mr *MockRequest) GetCookies() []*http.Cookie
- func (mr *MockRequest) GetHeaders() KeyValues
- func (mr *MockRequest) GetMethod() string
- func (mr *MockRequest) GetQueryParameters() KeyValues
- func (mr *MockRequest) GetRequest() *http.Request
- func (mr *MockRequest) GetURL() string
- func (mr *MockRequest) GetURLParameters() KeyValue
- type MockResponse
- func (mr *MockResponse) Bytes(data []byte) IResponse
- func (mr *MockResponse) CompareBody(other *MockResponse) bool
- func (mr *MockResponse) CompareHeaders(other *MockResponse) bool
- func (mr *MockResponse) CompareStatus(other *MockResponse) bool
- func (mr *MockResponse) Header(key string, value string) IResponse
- func (mr *MockResponse) JSON(data interface{}) IResponse
- func (mr *MockResponse) Status(statusCode int) IResponse
- func (mr *MockResponse) Text(text string) IResponse
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicRequest ¶
type BasicRequest struct {
URL string
Method string
Headers KeyValues
Cookies []*http.Cookie
URLParameters KeyValue
QueryParameters KeyValues
Body io.ReadCloser
Request *http.Request
}
func (*BasicRequest) GetBody ¶
func (br *BasicRequest) GetBody() io.ReadCloser
func (*BasicRequest) GetCookies ¶
func (br *BasicRequest) GetCookies() []*http.Cookie
func (*BasicRequest) GetHeaders ¶
func (br *BasicRequest) GetHeaders() KeyValues
func (*BasicRequest) GetMethod ¶
func (br *BasicRequest) GetMethod() string
func (*BasicRequest) GetQueryParameters ¶
func (br *BasicRequest) GetQueryParameters() KeyValues
func (*BasicRequest) GetRequest ¶ added in v1.1.5
func (br *BasicRequest) GetRequest() *http.Request
func (*BasicRequest) GetURL ¶
func (br *BasicRequest) GetURL() string
func (*BasicRequest) GetURLParameters ¶
func (br *BasicRequest) GetURLParameters() KeyValue
type BasicRoute ¶
type BasicRoute struct {
// contains filtered or unexported fields
}
func NewBasicRoute ¶
func NewBasicRoute(url string) *BasicRoute
func (*BasicRoute) Delete ¶ added in v1.1.0
func (br *BasicRoute) Delete(handlers ...Handler) IRoute
func (*BasicRoute) Get ¶ added in v1.1.0
func (br *BasicRoute) Get(handlers ...Handler) IRoute
func (*BasicRoute) Match ¶
func (br *BasicRoute) Match(targetURL string) bool
func (*BasicRoute) MultiMethod ¶ added in v1.1.1
func (br *BasicRoute) MultiMethod(methods []string, handlers ...Handler) IRoute
func (*BasicRoute) Patch ¶ added in v1.1.0
func (br *BasicRoute) Patch(handlers ...Handler) IRoute
func (*BasicRoute) Post ¶ added in v1.1.0
func (br *BasicRoute) Post(handlers ...Handler) IRoute
func (*BasicRoute) Put ¶ added in v1.1.0
func (br *BasicRoute) Put(handlers ...Handler) IRoute
type HTTPResponseWriterWrapper ¶
type HTTPResponseWriterWrapper struct {
// contains filtered or unexported fields
}
A wrapper of http.ResponseWriter that implements IResponse
func WrapHTTPResponseWriter ¶ added in v1.1.3
func WrapHTTPResponseWriter(rw http.ResponseWriter) *HTTPResponseWriterWrapper
func (*HTTPResponseWriterWrapper) Bytes ¶
func (w *HTTPResponseWriterWrapper) Bytes(bytes []byte) IResponse
Write bytes to the body
func (*HTTPResponseWriterWrapper) Header ¶
func (w *HTTPResponseWriterWrapper) Header(key string, value string) IResponse
Set a new header (Writes directly to http.ResponseWriter because the only thing that matters is the headers to be written first)
func (*HTTPResponseWriterWrapper) JSON ¶
func (w *HTTPResponseWriterWrapper) JSON(data interface{}) IResponse
Write JSON to the body (also sets Content-Type header)
func (*HTTPResponseWriterWrapper) Status ¶
func (w *HTTPResponseWriterWrapper) Status(statusCode int) IResponse
Writes a status code
func (*HTTPResponseWriterWrapper) Text ¶
func (w *HTTPResponseWriterWrapper) Text(text string) IResponse
Write text to the body
type IRequest ¶
type IRequest interface {
GetURL() string
GetMethod() string
GetHeaders() KeyValues
GetCookies() []*http.Cookie
GetURLParameters() KeyValue
GetQueryParameters() KeyValues
GetBody() io.ReadCloser
GetRequest() *http.Request
// contains filtered or unexported methods
}
func NewBasicRequest ¶
type IRoute ¶
type IRoute interface {
Match(url string) bool
Get(handlers ...Handler) IRoute
Post(handlers ...Handler) IRoute
Patch(handlers ...Handler) IRoute
Put(handlers ...Handler) IRoute
Delete(handlers ...Handler) IRoute
MultiMethod(methods []string, handlers ...Handler) IRoute
// contains filtered or unexported methods
}
type MockRequest ¶ added in v1.1.3
type MockRequest struct {
URL string
Method string
Headers KeyValues
Cookies []*http.Cookie
URLParameters KeyValue
QueryParameters KeyValues
// Fill in at most one of them
// Leave the rest empty
Body string // body that is a string
BodyJSON interface{} // object that will be converted to JSON and used as a body
}
func (*MockRequest) GetBody ¶ added in v1.1.3
func (mr *MockRequest) GetBody() io.ReadCloser
func (*MockRequest) GetCookies ¶ added in v1.1.3
func (mr *MockRequest) GetCookies() []*http.Cookie
func (*MockRequest) GetHeaders ¶ added in v1.1.3
func (mr *MockRequest) GetHeaders() KeyValues
func (*MockRequest) GetMethod ¶ added in v1.1.3
func (mr *MockRequest) GetMethod() string
func (*MockRequest) GetQueryParameters ¶ added in v1.1.3
func (mr *MockRequest) GetQueryParameters() KeyValues
func (*MockRequest) GetRequest ¶ added in v1.1.5
func (mr *MockRequest) GetRequest() *http.Request
func (*MockRequest) GetURL ¶ added in v1.1.3
func (mr *MockRequest) GetURL() string
func (*MockRequest) GetURLParameters ¶ added in v1.1.3
func (mr *MockRequest) GetURLParameters() KeyValue
type MockResponse ¶ added in v1.1.3
func NewMockResponse ¶ added in v1.1.3
func NewMockResponse() *MockResponse
func (*MockResponse) Bytes ¶ added in v1.1.3
func (mr *MockResponse) Bytes(data []byte) IResponse
func (*MockResponse) CompareBody ¶ added in v1.1.3
func (mr *MockResponse) CompareBody(other *MockResponse) bool
func (*MockResponse) CompareHeaders ¶ added in v1.1.3
func (mr *MockResponse) CompareHeaders(other *MockResponse) bool
func (*MockResponse) CompareStatus ¶ added in v1.1.3
func (mr *MockResponse) CompareStatus(other *MockResponse) bool
func (*MockResponse) Header ¶ added in v1.1.3
func (mr *MockResponse) Header(key string, value string) IResponse
func (*MockResponse) JSON ¶ added in v1.1.3
func (mr *MockResponse) JSON(data interface{}) IResponse
func (*MockResponse) Status ¶ added in v1.1.3
func (mr *MockResponse) Status(statusCode int) IResponse
func (*MockResponse) Text ¶ added in v1.1.3
func (mr *MockResponse) Text(text string) IResponse
Source Files
¶
Click to show internal directories.
Click to hide internal directories.