web

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: BSD-2-Clause Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	COOKIE_NAME = "GSESSION"
)

Variables

This section is empty.

Functions

func ResourcesHandler

func ResourcesHandler(dir string) http.Handler

ResourcesHandler creates a handler that serves files from a folder. If the broowser accepts gzip encoding, it will first try to serve the gzipped version of the file. If absent it will serve the non-gizzepd file. The gzip file name is the original file nane concatenated with '.gz'. Ex: index.html -> index.html.gz

Types

type BufferedResponse

type BufferedResponse struct {
	Body *bytes.Buffer

	Code int
	// contains filtered or unexported fields
}

func NewBufferedResponse

func NewBufferedResponse() *BufferedResponse

func (*BufferedResponse) Flush

func (this *BufferedResponse) Flush(w http.ResponseWriter)

func (*BufferedResponse) Header

func (this *BufferedResponse) Header() http.Header

func (*BufferedResponse) Write

func (this *BufferedResponse) Write(data []byte) (int, error)

func (*BufferedResponse) WriteBefore

func (this *BufferedResponse) WriteBefore(data []byte) error

WriteBefore writes data at the beginning of the buffer. It does this by copying the original data, truncating the buffer, then writing what we want and then write the original data.

func (*BufferedResponse) WriteHeader

func (this *BufferedResponse) WriteHeader(code int)

type HttpFail

type HttpFail struct {
	*toolkit.Fail

	Status int
}

func NewHttpFail

func NewHttpFail(status int, code string, message string) *HttpFail

type ISession

type ISession interface {
	GetId() string
	Invalidate()
	IsInvalid() bool
	Get(key interface{}) interface{}
	Delete(key interface{})
	Put(key interface{}, value interface{})
}

type NeuteredReadirFile

type NeuteredReadirFile struct {
	http.File
}

func (NeuteredReadirFile) Readdir

func (f NeuteredReadirFile) Readdir(count int) ([]os.FileInfo, error)

type OnlyFilesFS

type OnlyFilesFS struct {
	Fs http.FileSystem
}

blocks directory listing and accessing content outside the document base (root)

func (OnlyFilesFS) Open

func (this OnlyFilesFS) Open(name string) (http.File, error)

type Session

type Session struct {
	Id         string
	Attributes map[interface{}]interface{}
	Invalid    bool // if true it will be invalidate (removal from Sessions) at the end of the request.
}

func NewSession

func NewSession() *Session

func (*Session) Delete

func (this *Session) Delete(key interface{})

func (*Session) Get

func (this *Session) Get(key interface{}) interface{}

func (*Session) GetId

func (this *Session) GetId() string

func (*Session) Init

func (this *Session) Init()

func (*Session) Invalidate

func (this *Session) Invalidate()

func (*Session) IsInvalid

func (this *Session) IsInvalid() bool

func (*Session) Put

func (this *Session) Put(key interface{}, value interface{})

type Sessions

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

func NewSessions

func NewSessions(config SessionsConfig) *Sessions

func (*Sessions) CreateNewSession

func (this *Sessions) CreateNewSession() ISession

func (*Sessions) Delete

func (this *Sessions) Delete(r *http.Request)

func (*Sessions) GetIfPresent

func (this *Sessions) GetIfPresent(id string) ISession

func (*Sessions) GetOrCreate

func (this *Sessions) GetOrCreate(w http.ResponseWriter, r *http.Request, create bool) ISession

gets the session identified by id. If not found and if 'create' equals to 'true' then creates a new session

func (*Sessions) Invalidate

func (this *Sessions) Invalidate(session ISession)

type SessionsConfig

type SessionsConfig struct {
	Timeout    time.Duration
	Interval   time.Duration
	Factory    func() ISession
	CookieName string
}

Directories

Path Synopsis
example command

Jump to

Keyboard shortcuts

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