Documentation ¶
Index ¶
- type CHC
- func (chc *CHC) AddRoute(route *Route)
- func (chc *CHC) AddRoutes(routes []*Route)
- func (chc *CHC) GetEnv(key string) string
- func (chc *CHC) Listen(host string, port int)
- func (chc *CHC) LoadEnv(filePath string)
- func (chc *CHC) NewRoute(path string, methods []string, type_ string, headers map[string]string, ...) *Route
- func (chc *CHC) RequestLogging(logging bool)
- type Request
- type Response
- func (response *Response) GetImageBytes(filepath string) ([]byte, error)
- func (response *Response) LoadHtmlFile(filePath string) error
- func (response *Response) LoadImageFile(filePath string) error
- func (response *Response) SetCookie(key string, value string)
- func (response *Response) SetHeader(key string, value string)
- func (response *Response) SetJsonArrayBody(array []map[string]interface{}) error
- func (response *Response) SetJsonObjectBody(object map[string]interface{}) error
- func (response *Response) SetRedirect(url string)
- func (response *Response) SetStatusCode(statusCode int)
- func (response *Response) SetStringBody(body string)
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CHC ¶
func (*CHC) NewRoute ¶
func (chc *CHC) NewRoute(path string, methods []string, type_ string, headers map[string]string, file string, controller func(request *Request) (response *Response)) *Route
Create a new route object
func (*CHC) RequestLogging ¶
Turn Request Logging on or off (if using NewCHC function default is on, otherwise default is off)
type Request ¶
type Request struct { Method string URL string Protocol string Body string Params map[string]string Headers map[string]string Cookies map[string]string Conn net.Conn }
func (*Request) FormDataBody ¶
Parse the request body as Form Data and return the result as a map
func (*Request) JsonArrayBody ¶
Parse the request body as a JSON array and return the result as a map
func (*Request) NewResponse ¶ added in v1.1.2
Create a new response object
type Response ¶
type Response struct { StatusCode int Body string Headers map[string]string Cookies map[string]string Conn net.Conn }
func (*Response) GetImageBytes ¶
Get the bytes from and image file
func (*Response) LoadHtmlFile ¶
Load a HTML file from a path and set the content type to text/html
func (*Response) LoadImageFile ¶
Set the response to an image from a path
func (*Response) SetJsonArrayBody ¶
Set the response body to a json array
func (*Response) SetJsonObjectBody ¶
Set the response body to a json object
func (*Response) SetRedirect ¶
Set the response redirect to a url
func (*Response) SetStatusCode ¶
Set the status code for the response
func (*Response) SetStringBody ¶
Set the response body to a string
type Route ¶
type Route struct { Path string Methods []string Type string Headers map[string]string File string Controller func(request *Request) (response *Response) Middleware []func(request *Request) (response *Response) }
func (*Route) AddMiddleware ¶
Add a middleware to a route
func (*Route) AddMiddlewares ¶
Add multiple middleware to a route