util

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagParameterType   = "flag"
	BoolParameterType   = "bool"
	IntParameterType    = "int"
	StringParameterType = "string"
	ListParameterType   = "list"
)

Variables

This section is empty.

Functions

func AcceptedMediaType

func AcceptedMediaType(r *http.Request, validList []string) error

AcceptedMediaType validates the media type in the "Accept" header for this request against a list of valid media types. This includes common types that are always accepted, as well as additional types provided as paraameters to this function call. The result is a nil error value if the media type is valid, else an error indicating that there was an invalid media type found.

func Decrypt

func Decrypt(data, password string) (string, error)

Decrypt decrypts a string using a password.

func Encrypt

func Encrypt(data, password string) (string, error)

Encrypt encrypts a string using a password.

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, sessionID int32, msg string, status int)

func HasCapitalizedName

func HasCapitalizedName(name string) bool

HasCapitalizedName returns true if the first rune/character of the string is considered a capital letter in Unicode.

func Hash

func Hash(key string) string

Hash creates a hash string from a key string. The hash cannot be reversed back into the key string, but two instances of the same key string result in the same hash value.

func Hostname

func Hostname() string

Hostname gets a short form of the host namme (i.e. the first part of an FQDN).

func InList

func InList(s string, test ...string) bool

InList is a support function that checks to see if a string matches any of a list of other strings.

func InterfaceMapKeys

func InterfaceMapKeys(data map[string]interface{}) []string

func MakeBaseCollection

func MakeBaseCollection(sessionID int32) defs.BaseCollection

func MakeServerInfo

func MakeServerInfo(sessionID int32) defs.ServerInfo

func MakeSortedArray

func MakeSortedArray(array []string) *data.Array

Given a list of strings, convert them to a sorted list in Ego array format.

func SessionLog

func SessionLog(id int32, text string) string

Session log is used to take a multi-line message for the server log, and insert prefixes on each line with the session number so the log lines will be tagged with the appropriate session identifier, and can be read with the server log query for a specific session.

func Unquote

func Unquote(s string) string

Unquote removes quotation marks from a string if present.

func ValidateParameters

func ValidateParameters(u *url.URL, validation map[string]string) error

ValidateParameters checks the parameters in a previously-parsed URL against a map describing the expected parameters and types. IF there is no error, the function returns nil, else an error describing the first parameter found that was invalid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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