utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2017 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeUTF8

func DecodeUTF8(bytes []byte) string

DecodeUTF8 is equivalent to .decode('utf-8', 'ignore') in Python

func GetHTTPClient

func GetHTTPClient() *http.Client

GetHTTPClient returns the shared HTTP client used by all Courier threads

func JoinNonEmpty

func JoinNonEmpty(delim string, strings ...string) string

JoinNonEmpty takes a vararg of strings and return the join of all the non-empty strings with a delimiter between them

func MakeHTTPRequest

func MakeHTTPRequest(req *http.Request) (*http.Response, []byte, error)

MakeHTTPRequest fires the passed in http request using our shared client, returning the response and any errors

func MapAsJSON

func MapAsJSON(m map[string]string) []byte

MapAsJSON serializes the given map as a JSON string

func PutS3File

func PutS3File(s3Client *s3.S3, bucket string, path string, contentType string, contents []byte) (string, error)

func StringArrayContains

func StringArrayContains(s []string, e string) bool

StringArrayContains returns whether a given string array contains the given element

func TestS3

func TestS3(s3Client *s3.S3, bucket string) error

Types

type NullMap

type NullMap struct {
	Map   map[string]interface{}
	Valid bool
}

NullMap is a one level deep dictionary that is represented as JSON in the database

func (*NullMap) MarshalJSON

func (n *NullMap) MarshalJSON() ([]byte, error)

MarshalJSON decodes our dictionary from the passed in bytes

func (*NullMap) Scan

func (n *NullMap) Scan(src interface{}) error

Scan implements the Scanner interface for decoding from a database

func (*NullMap) UnmarshalJSON

func (n *NullMap) UnmarshalJSON(data []byte) error

UnmarshalJSON sets our dict from the passed in data

func (*NullMap) Value

func (n *NullMap) Value() (driver.Value, error)

Value implements the driver Valuer interface

Jump to

Keyboard shortcuts

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