Documentation
¶
Index ¶
Constants ¶
const ( ContentTypeHeader = "Content-Type" ContentTypeJSON = "application/json" )
ContentType header possible values
const (
ETagHeader = "ETag"
)
Variables ¶
This section is empty.
Functions ¶
func GenerateETag ¶
GenerateETag generates a SHA-1 hash of the body with type []byte. SHA-1 is not cryptographically safe, but it has been selected for performance as we are only interested in uniqueness. A strong or weak eTag can be generated. Please note that ETags are surrounded by double quotes.
Example: ETag = `"24decf55038de874bc6fa9cf0930adc219f15db1"`
The definition of ETag is explained in https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
func SetETag ¶
func SetETag(w http.ResponseWriter, newETag string)
SetETag sets the new eTag of the resource in the header. Please note that ETags are surrounded by double quotes.
Example: ETag = `"24decf55038de874bc6fa9cf0930adc219f15db1"`
Types ¶
type JSONEncoder ¶
type JSONEncoder interface {
WriteResponseJSON(w http.ResponseWriter, value interface{}, status int) error
}
JSONEncoder interface defining a JSON encoder.
var JsonResponseEncoder JSONEncoder = &OnsJSONEncoder{}
type OnsJSONEncoder ¶
type OnsJSONEncoder struct{}
OnsJSONEncoder is a JSON encoder
func (*OnsJSONEncoder) WriteResponseJSON ¶
func (j *OnsJSONEncoder) WriteResponseJSON(w http.ResponseWriter, value interface{}, status int) error
WriteResponseJSON marshals the provided value as json body, and sets the status code to the provided value