Documentation ¶
Index ¶
- Constants
- func DeleteHTTPHeader(r *http.Request, headerNameToDelete string) (err error)
- func FindHTTPHeader(r *http.Request, headerNameAsked string) (hdr string, err error)
- func PerformAverageHttpTest(test *AverageTest) (err error)
- func PerformSimpleHttpTest(test *SimpleTest) (err error)
- func ReceiveJSON(r *http.Request, receiver interface{}) (err error)
- func ReplyErrorInternal(w http.ResponseWriter, err error)
- func ReplyErrorWithCode(w http.ResponseWriter, httpStatusCode int, err error)
- func ReplyJSON(w http.ResponseWriter, replyObject interface{})
- func ReplyJSONFast(w http.ResponseWriter, replyObject interface{})
- func ReplyTextWithCode(w http.ResponseWriter, httpStatusCode int, replyText string)
- type AverageTest
- type AverageTestParameter
- type AverageTestResult
- type SimpleTest
- type SimpleTestParameter
- type SimpleTestResult
Constants ¶
const ( ErrHTTPHeaderNameIsNotSet = "HTTP Header Name is not set" ErrHTTPHeaderNameIsNotFound = "HTTP Header Name is not found" )
Errors
const (
ErrNotPointer = "not a pointer"
)
Errors.
const (
ErrNullPointer = "null pointer"
)
Errors.
Variables ¶
This section is empty.
Functions ¶
func DeleteHTTPHeader ¶
DeleteHTTPHeader function tries to delete a header from the HTTP request.
func FindHTTPHeader ¶
FindHTTPHeader function tries to find the HTTP header with name similar to the specified one. According to the Section 4.2 of RFC 2616, HTTP header names are case-insensitive. On success, returns 'nil' and the exact header name which was found.
func PerformAverageHttpTest ¶
func PerformAverageHttpTest(test *AverageTest) (err error)
PerformAverageHttpTest function performs the simulation of an average HTTP test handler. It writes the received results into the 'ResultReceived' field of a test object.
func PerformSimpleHttpTest ¶
func PerformSimpleHttpTest(test *SimpleTest) (err error)
PerformSimpleHttpTest function performs the simulation of a simple HTTP test handler. It writes the received results into the 'ResultReceived' field of a test object.
func ReceiveJSON ¶
ReceiveJSON function receives an object encoded with JSON format from the HTTP request's body.
func ReplyErrorInternal ¶
func ReplyErrorInternal(w http.ResponseWriter, err error)
ReplyErrorInternal function replies to the HTTP request with an error and 'Internal Server Error' HTTP status code.
func ReplyErrorWithCode ¶
func ReplyErrorWithCode(w http.ResponseWriter, httpStatusCode int, err error)
ReplyErrorWithCode function replies to the HTTP request with an error and the specified HTTP status code.
func ReplyJSON ¶
func ReplyJSON(w http.ResponseWriter, replyObject interface{})
ReplyJSON function sends an object in JSON format to the HTTP output stream.
func ReplyJSONFast ¶
func ReplyJSONFast(w http.ResponseWriter, replyObject interface{})
ReplyJSONFast function sends an object in JSON format to the HTTP output stream using the faster but less secure way than an ordinary 'ReplyJSON' method.
func ReplyTextWithCode ¶
func ReplyTextWithCode(w http.ResponseWriter, httpStatusCode int, replyText string)
ReplyTextWithCode function replies to the HTTP request with the specified text and HTTP status code.
Types ¶
type AverageTest ¶
type AverageTest struct { Parameter AverageTestParameter ResultExpected AverageTestResult ResultReceived AverageTestResult }
AverageTest is an average HTTP test.
type AverageTestParameter ¶
type AverageTestParameter struct { RequestMethod string RequestUrl string RequestHeaders http.Header RequestBody io.Reader RequestHandler http.HandlerFunc }
AverageTestParameter is a parameter of an average HTTP test.
type AverageTestResult ¶
type AverageTestResult struct { ResponseStatusCode int ResponseHeaders http.Header ResponseBody []byte }
AverageTestResult is a result of an average HTTP test.
type SimpleTest ¶
type SimpleTest struct { Parameter SimpleTestParameter ResultExpected SimpleTestResult ResultReceived SimpleTestResult }
SimpleTest is a simple HTTP test.
type SimpleTestParameter ¶
type SimpleTestParameter struct { RequestMethod string RequestUrl string RequestBody io.Reader RequestHandler http.HandlerFunc }
SimpleTestParameter is a parameter of a simple HTTP test.
type SimpleTestResult ¶
SimpleTestResult is a result of a simple HTTP test.