Documentation ¶
Overview ¶
Package util provides utility functions specific to the http-end-point component of Documize.
Index ¶
- func EncodeHTMLString(html string) (safe string)
- func EncodeTextTemplate(html string) (safe string, err error)
- func GeneratePassword(password string, salt string) string
- func GenerateRandom(size int) string
- func GenerateRandomPassword() string
- func GenerateSalt() string
- func MatchPassword(hashedPassword string, password string, salt string) bool
- func Params(r *http.Request) map[string]string
- func UniqueID() string
- func WriteBadRequestError(w http.ResponseWriter, method, message string)
- func WriteDuplicateError(w http.ResponseWriter, method, entity string)
- func WriteForbiddenError(w http.ResponseWriter)
- func WriteGeneralSQLError(w http.ResponseWriter, method string, err error)
- func WriteJSON(w http.ResponseWriter, v interface{})
- func WriteJSONMarshalError(w http.ResponseWriter, method, entity string, err error)
- func WriteMarshalError(w http.ResponseWriter, err error)
- func WriteMissingDataError(w http.ResponseWriter, method, parameter string)
- func WriteNotFoundError(w http.ResponseWriter, method string, id string)
- func WritePayloadError(w http.ResponseWriter, method string, err error)
- func WriteServerError(w http.ResponseWriter, method string, err error)
- func WriteSuccessBytes(w http.ResponseWriter, data []byte)
- func WriteSuccessEmptyJSON(w http.ResponseWriter)
- func WriteSuccessString(w http.ResponseWriter, data string)
- func WriteTransactionError(w http.ResponseWriter, method string, err error)
- func WriteUnauthorizedError(w http.ResponseWriter)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeHTMLString ¶
EncodeHTMLString encodes HTML string
func EncodeTextTemplate ¶
EncodeTextTemplate encodes input using text/template
func GeneratePassword ¶
GeneratePassword returns a hashed password.
func GenerateRandom ¶
GenerateRandom returns a string of the specified length using crypo/rand
func GenerateRandomPassword ¶
func GenerateRandomPassword() string
GenerateRandomPassword provides a string suitable for use as a password.
func GenerateSalt ¶
func GenerateSalt() string
GenerateSalt provides a string suitable for use as a salt value.
func MatchPassword ¶
MatchPassword copares a hashed password with a clear one.
func UniqueID ¶
func UniqueID() string
UniqueID creates a randomly generated string suitable for use as part of an URI. It returns a string that is always 16 characters long.
func WriteBadRequestError ¶
func WriteBadRequestError(w http.ResponseWriter, method, message string)
func WriteDuplicateError ¶
func WriteDuplicateError(w http.ResponseWriter, method, entity string)
func WriteForbiddenError ¶
func WriteForbiddenError(w http.ResponseWriter)
func WriteGeneralSQLError ¶
func WriteGeneralSQLError(w http.ResponseWriter, method string, err error)
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v interface{})
WriteJSON serializes data as JSON to HTTP response.
func WriteJSONMarshalError ¶
func WriteJSONMarshalError(w http.ResponseWriter, method, entity string, err error)
func WriteMarshalError ¶
func WriteMarshalError(w http.ResponseWriter, err error)
func WriteMissingDataError ¶
func WriteMissingDataError(w http.ResponseWriter, method, parameter string)
func WriteNotFoundError ¶
func WriteNotFoundError(w http.ResponseWriter, method string, id string)
func WritePayloadError ¶
func WritePayloadError(w http.ResponseWriter, method string, err error)
func WriteServerError ¶
func WriteServerError(w http.ResponseWriter, method string, err error)
func WriteSuccessBytes ¶
func WriteSuccessBytes(w http.ResponseWriter, data []byte)
func WriteSuccessEmptyJSON ¶
func WriteSuccessEmptyJSON(w http.ResponseWriter)
func WriteSuccessString ¶
func WriteSuccessString(w http.ResponseWriter, data string)
func WriteTransactionError ¶
func WriteTransactionError(w http.ResponseWriter, method string, err error)
func WriteUnauthorizedError ¶
func WriteUnauthorizedError(w http.ResponseWriter)
Types ¶
This section is empty.