Documentation ¶
Index ¶
- Variables
- func GetHostname(r *http.Request) string
- func GetRemoteAddr(r *http.Request) string
- func IsAlphaNum(s string) bool
- func Jsonify(w http.ResponseWriter, v interface{})
- func ParseBody(r *http.Request, v interface{}) error
- func RandomString(n int) string
- func ReadRSAPemKey(path string) (*rsa.PrivateKey, error)
- func StripPort(hostport string) string
- func WaitSignal(sig ...os.Signal)
- type FlagArray
- type RequestBody
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyMustBePEMEncoded = errors.New("must be PEM encoded PKCS1 or PKCS8 private key") ErrNotRSAPrivateKey = errors.New("not a valid RSA private key") )
var (
ErrInvalidContentType = errors.New("invalid content type")
)
Functions ¶
func GetHostname ¶ added in v1.0.1
GetHostname return the Host Header of an http request. The Host is stripped from any port.
func GetRemoteAddr ¶
GetRemoteAddr returns the remote address of an http request. If an X-Forwarded-For Header is present the headers content is returned. Otherwise the src host of the ip packet is returned.
func IsAlphaNum ¶ added in v1.0.2
IsAlphaNum returns true if the given string is composed of letters and digits only. Otherwise false is returned.
func Jsonify ¶
func Jsonify(w http.ResponseWriter, v interface{})
Jsonify writes the JSON representation of v to the supplied http.ResposeWriter. If an error occours while marshalling the http response will be an internal server error.
func RandomString ¶
RandomString string returns a random string with the length n. Stolen from https://stackoverflow.com/questions/22892120/how-to-generate-a-random-tring-of-a-fixed-length-in-golang
func ReadRSAPemKey ¶ added in v1.0.1
func ReadRSAPemKey(path string) (*rsa.PrivateKey, error)
ReadRSAPemKey read the PEM encoded RSA private key from the filesystem.
func WaitSignal ¶
WaitSignal blocks until one of the given OS signals occoures.
Types ¶
type FlagArray ¶ added in v1.1.0
type FlagArray []string
FlagArray is a type which could be used with the flag package, to obtain a list from multiple flags with the same name but different values. e.g.: ./test --foo=bar --foo=test --foo=x
type RequestBody ¶ added in v1.0.1
RequestBody represents the body of a request which was saved with SaveRequestBody().
func SaveRequestBody ¶ added in v1.0.1
func SaveRequestBody(r *http.Request) *RequestBody
SaveRequestBody saves the body of a request in order to restore it later.