webeh

package module
v0.0.0-...-2d67580 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 15 Imported by: 0

README

webeh

Build Status MIT License

Some Helpers to use http easier in golang

Please user argcv/stork instead.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessControlAllowCredentials = true
View Source
var AccessControlAllowHeaders = []string{
	"Content-Type",
	"Content-Length",
	"Accept-Encoding",
	"Content-Range",
	"Content-Disposition",
	"Authorization",
	"X-Requested-With",
}
View Source
var AccessControlAllowMethods = []string{
	"POST",
	"GET",
	"OPTIONS",
	"PUT",
	"PATCH",
	"DELETE",
}

Functions

func Adapt

func Adapt(h http.Handler, adapters ...Adapter) http.Handler

func GetCookie

func GetCookie(r *http.Request, name string) (*sessions.Session, error)

Get returns a session for the given name after adding it to the registry.

It returns a new session if the sessions doesn't exist. Access IsNew on the session to check if it is an existing session or a new one.

It returns a new session and an error if the session exists but could not be decoded.

func GetCookieKeyPairs

func GetCookieKeyPairs() (keyPairs string)

func GetCookieStore

func GetCookieStore() *sessions.CookieStore

func GetUserIp

func GetUserIp(r *http.Request) string

func Log

func Log(v ...interface{})

func Logf

func Logf(f string, v ...interface{})

func NewCookie

func NewCookie(r *http.Request, name string) (*sessions.Session, error)

New returns a session for the given name without adding it to the registry.

The difference between New() and Get() is that calling New() twice will decode the session data twice, while Get() registers and reuses the same decoded session after the first call.

func ReplyJson

func ReplyJson(w http.ResponseWriter, ret interface{}) (int, error)

func ReplyJsonWithCode

func ReplyJsonWithCode(w http.ResponseWriter, ret interface{}, code int) (int, error)

func SaveCookie

func SaveCookie(r *http.Request, w http.ResponseWriter, s *sessions.Session) error

Save adds a single session to the response.

func SetCookieKeyPairs

func SetCookieKeyPairs(keyPairs string)

func WebLog

func WebLog(r *http.Request, v ...interface{})

func WebLogf

func WebLogf(r *http.Request, f string, v ...interface{})

Types

type Adapter

type Adapter func(http.Handler) http.Handler

func CORSMiddleware

func CORSMiddleware() Adapter

type FileInfo

type FileInfo struct {
	Filename string
	Header   textproto.MIMEHeader
	Size     int64
	Path     string
	Ext      string
}

type MultipartFormReader

type MultipartFormReader struct {
	R *http.Request
}

func NewMultipartFormReader

func NewMultipartFormReader(r *http.Request, options ...MultipartFormReaderOption) (mr *MultipartFormReader)

func (*MultipartFormReader) GetString

func (mr *MultipartFormReader) GetString(field string) string

func (*MultipartFormReader) HandleFile

func (mr *MultipartFormReader) HandleFile(field string, f func(multipart.File, *multipart.FileHeader) error) (err error)

func (*MultipartFormReader) SaveFile

func (mr *MultipartFormReader) SaveFile(field string, path, name string) (fileInfo FileInfo, err error)

type MultipartFormReaderOption

type MultipartFormReaderOption struct {
	MaxMemoryMB int64
}

func NewDefaultMultipartFormReaderOption

func NewDefaultMultipartFormReaderOption() MultipartFormReaderOption

type Once

type Once struct {
	// contains filtered or unexported fields
}

STATUS: 0: not executed yet 1: in progressing... 2: done

func (*Once) Do

func (o *Once) Do(f func())

call once

func (*Once) Reset

func (o *Once) Reset()

call once again in the future

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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