utils

package
v0.0.0-...-eca9d05 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidContentType is returned by ParseRequest if it can't unmarshal it into the passed struct
	ErrInvalidContentType = errors.New("Invalid request content type")
)

Functions

func FileExists

func FileExists(name string) bool

FileExists is a stupid little wrapper of os.Stat that checks whether a file exists

func GetAlgorithmName

func GetAlgorithmName(id packet.PublicKeyAlgorithm) string

GetAlgorithmName returns algorithm's name depending on its ID

func HoursFromNowString

func HoursFromNowString(n int) string

HoursFromNowString returns time.Now + n hours in string format. The result is RFC3339 encoded and in UTC. This makes it possible to compare the times with a simple string comparison. Example: "2006-12-30T15:34:45Z00:00"

func JSONResponse

func JSONResponse(w http.ResponseWriter, status int, data interface{})

JSONResponse writes JSON to an http.ResponseWriter with the corresponding status code

func NormalizeUsername

func NormalizeUsername(input string) string

func ParseRequest

func ParseRequest(r *http.Request, data interface{}) error

ParseRequest takes the input body from the passed request and tries to unmarshal it into data

func RemoveDots

func RemoveDots(input string) string

func StringToTime

func StringToTime(in string) (time.Time, error)

StringToTime returns a time.Time object from a RFC3339-encoded string.

func TimeNowString

func TimeNowString() string

TimeNowString returns time.Now + UTC + Format(RFC3339). This makes the strings comparable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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