util

package
v0.0.0-...-4685c53 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeKey   = "Content-Type"
	ContentLengthKey = "Content-Length"
	ContentTypeJSON  = "application/json"
	ContentTypeText  = "text/plain"
)
View Source
const (
	ReIdentifier = `[a-zA-Z][a-zA-Z0-9_\-]+`
)

Variables

This section is empty.

Functions

func Fqn

func Fqn(value ...string) string

Fqn returns a fully-qualified value, which includes a trailing dot

func IsIdentifier

func IsIdentifier(s string) bool

func IsWritableDir

func IsWritableDir(path string) (bool, error)

IsWritableDir returns true if the given directory path is writable

func MD5Hash

func MD5Hash(data []byte) string

func ServeEmpty

func ServeEmpty(w http.ResponseWriter, code uint)

ServeEmpty is a utility function to serve an empty response

func ServeError

func ServeError(w http.ResponseWriter, code uint, reason ...string) error

ServeError is a utility function to serve a JSON error notice

func ServeJSON

func ServeJSON(w http.ResponseWriter, v interface{}, code, indent uint) error

ServeJSON is a utility function to serve an arbitary object as JSON

func ServeText

func ServeText(w http.ResponseWriter, v string, code uint)

ServeText is a utility function to serve plaintext

func Unfqn

func Unfqn(value, domain string) string

Unfqn remove final domain separator and domain

Types

type ErrorResponse

type ErrorResponse struct {
	Code   uint   `json:"code"`
	Reason string `json:"reason,omitempty"`
}

Jump to

Keyboard shortcuts

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