helpers

package
v0.0.1-tiedot Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2014 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Generate a self-signed X.509 certificate for a TLS server. Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files. Cyrill: created a struct with a method to use it internally

Index

Constants

View Source
const (
	DEFAULT_TLS_SESSION_CACHE_CAPACITY int = 128
)

Variables

This section is empty.

Functions

func CreateDirectoryIfNotExists

func CreateDirectoryIfNotExists(path string)

func DecodeJSON

func DecodeJSON(r *http.Request, value interface{}) error

func Ffjson_FormatBits

func Ffjson_FormatBits(dst *bytes.Buffer, u uint64, base int, neg bool)

func Ffjson_WriteJsonString

func Ffjson_WriteJsonString(buf *bytes.Buffer, s string)

func GeneratePems

func GeneratePems(listenAddress, pemDir, certFileName, keyFileName string) (string, error)

GeneratePems creates new PEM files if they not yet exists returns the name of the PEM directory and error|nil

func GetTempDir

func GetTempDir() string

returns the OS default temp dir with trailing slash

func GetTlsConfig

func GetTlsConfig() *tls.Config

func NewPassword

func NewPassword(length int) (string, error)

generates a random string with the crypto package

func PathExists

func PathExists(path string) (bool, error)

func RandomInt

func RandomInt(n int) int

func RandomString

func RandomString(length int) string

randomString generates a pseudo-random alpha-numeric string with given length.

func RenderFFJSON

func RenderFFJSON(w http.ResponseWriter, value FfjsonIf, status int) error

func RenderJSON

func RenderJSON(w http.ResponseWriter, value interface{}, status int) error

func RenderString

func RenderString(w http.ResponseWriter, status int, msg string) error

func StringHash

func StringHash(str string) int

Hash a string using sdbm algorithm.

func ValidateEmail

func ValidateEmail(email string) bool

ValidateEmail does what is says in a simple way and without regex. everybody is doing it with regex ;-)

func ValidateListenAddress

func ValidateListenAddress(address string) (string, string, error)

func WriteBody

func WriteBody(w http.ResponseWriter, body []byte, status int, contentType string) error

Types

type FfjsonIf

type FfjsonIf interface {
	MarshalJSON() ([]byte, error)
	MarshalJSONBuf(buf *bytes.Buffer) error
}

Jump to

Keyboard shortcuts

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