util

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2017 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package util provides utility functions specific to the http-end-point component of Documize.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeHTMLString

func EncodeHTMLString(html string) (safe string)

EncodeHTMLString encodes HTML string

func EncodeTextTemplate

func EncodeTextTemplate(html string) (safe string, err error)

EncodeTextTemplate encodes input using text/template

func GeneratePassword

func GeneratePassword(password string, salt string) string

GeneratePassword returns a hashed password.

func GenerateRandom

func GenerateRandom(size int) string

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 GetContentLinks(body string) (links []entity.Link)

GetContentLinks returns Documize generated <a> links. such links have an identifying attribute e.g. <a data-documize='true'...

func MatchPassword

func MatchPassword(hashedPassword string, password string, salt string) bool

MatchPassword copares a hashed password with a clear one.

func Params

func Params(r *http.Request) map[string]string

Params returns the paramaters to a gorilla mux request.

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)

WriteBadRequestError error handling

func WriteDuplicateError

func WriteDuplicateError(w http.ResponseWriter, method, entity string)

WriteDuplicateError error handling

func WriteForbiddenError

func WriteForbiddenError(w http.ResponseWriter)

WriteForbiddenError error handling

func WriteGeneralSQLError

func WriteGeneralSQLError(w http.ResponseWriter, method string, err error)

WriteGeneralSQLError error handling

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)

WriteJSONMarshalError error handling

func WriteMarshalError

func WriteMarshalError(w http.ResponseWriter, err error)

WriteMarshalError error handling

func WriteMissingDataError

func WriteMissingDataError(w http.ResponseWriter, method, parameter string)

WriteMissingDataError error handling

func WriteNotFoundError

func WriteNotFoundError(w http.ResponseWriter, method string, id string)

WriteNotFoundError error handling

func WritePayloadError

func WritePayloadError(w http.ResponseWriter, method string, err error)

WritePayloadError error handling

func WriteServerError

func WriteServerError(w http.ResponseWriter, method string, err error)

WriteServerError error handling

func WriteSuccessBytes

func WriteSuccessBytes(w http.ResponseWriter, data []byte)

WriteSuccessBytes dumps bytes to HTTP response

func WriteSuccessEmptyJSON

func WriteSuccessEmptyJSON(w http.ResponseWriter)

WriteSuccessEmptyJSON writes empty JSON HTTP response

func WriteSuccessString

func WriteSuccessString(w http.ResponseWriter, data string)

WriteSuccessString writes string to HTTP response

func WriteTransactionError

func WriteTransactionError(w http.ResponseWriter, method string, err error)

WriteTransactionError error handling

func WriteUnauthorizedError

func WriteUnauthorizedError(w http.ResponseWriter)

WriteUnauthorizedError error handling

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL