webapp

package
v0.0.0-...-6da8fc5 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2012 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILE_STORAGE_MODE_SINGLE  = 0
	FILE_STORAGE_MODE_MULIPLE = 1
)
View Source
const (
	ERROR_UNKNOWN         = "Unknown Error"
	ERROR_KEY_NOT_EXISTS  = "Key doesn't exists"
	ERROR_IMPERMEABLE_KEY = "Impereable Key"
)
View Source
const (
	ErrNotFound            = "Page Not Found"
	ErrAccessDenied        = "Access Denied"
	ErrInternalServerError = "Internal Server Error"
)
View Source
const (
	OP_SAVE = 0
)

Variables

View Source
var EmailPattern, URLPattern *regexp.Regexp

Functions

func CheckEmailForm

func CheckEmailForm(in string) bool

func CheckForm

func CheckForm(re *regexp.Regexp, in string) bool

func CheckURLForm

func CheckURLForm(in string) bool

func TransformTags

func TransformTags(in string) string

Types

type AbsApp

type AbsApp interface {
	Run()
	AddHandleFunc(string, func(http.ResponseWriter, *http.Request))
	SetStaticPath(string, string)
}

type App

type App struct {
	Port    int
	Handler RootHandler
}

func (*App) AccessLog

func (app *App) AccessLog(ctx *Context)

func (*App) ErrorLog

func (app *App) ErrorLog(ctx *Context)

func (*App) Log

func (app *App) Log(tag string, msg string)

func (*App) Run

func (app *App) Run(port int)

func (*App) RunCGI

func (app *App) RunCGI(port int)

func (*App) SetHandler

func (app *App) SetHandler(url string, handleFunc func(*Context))

func (*App) SetStaticPath

func (app *App) SetStaticPath(url string, path string)

type Context

type Context struct {
	Writer      http.ResponseWriter
	Request     *http.Request
	Application *App
	Info        ContextInfo
	Headers     map[string]string
}

func (*Context) Error

func (ctx *Context) Error(msg string, code int)

func (*Context) Execute

func (ctx *Context) Execute(tpl *template.Template, data interface{}) error

func (*Context) Redirect

func (ctx *Context) Redirect(url string, code int)

func (*Context) SetHeader

func (ctx *Context) SetHeader(key string, val string)

type ContextInfo

type ContextInfo struct {
	StartTime time.Time
	During    int64
	URL       string
	HttpCode  int
	Message   string
	UseGZip   bool
}

type FileStorage

type FileStorage struct {
	Path  string
	Mode  int
	Index map[string]string
	Stat  StorageStat
	// @TODO
	GetChan chan string
	SetChan chan string
	CmdChan chan *StorageCmdItem
}

func (*FileStorage) Count

func (fs *FileStorage) Count() int

func (*FileStorage) Delete

func (fs *FileStorage) Delete(key string)

func (*FileStorage) Get

func (fs *FileStorage) Get(key string) ([]byte, error)

func (*FileStorage) GetJSON

func (fs *FileStorage) GetJSON(key string) (interface{}, error)

Gets string form storage assigned with specified key, coverts it to json object and returns. if this key doesn't exists or failed to parse json, return nil, err

func (*FileStorage) GetString

func (fs *FileStorage) GetString(key string) (string, error)

func (*FileStorage) Has

func (fs *FileStorage) Has(key string) bool

func (*FileStorage) Init

func (fs *FileStorage) Init(path string, mode int) error

func (*FileStorage) LoadIndex

func (fs *FileStorage) LoadIndex() error

func (*FileStorage) Master

func (fs *FileStorage) Master()

func (*FileStorage) SaveIndex

func (fs *FileStorage) SaveIndex() error

func (*FileStorage) Set

func (fs *FileStorage) Set(key string, value []byte) error

func (*FileStorage) SetJSON

func (fs *FileStorage) SetJSON(key string, value interface{}) error

func (*FileStorage) SetString

func (fs *FileStorage) SetString(key string, value string) error

type RenderHandler

type RenderHandler func(*App, map[string]string) (string, error)

type RootHandler

type RootHandler struct {
	HandleFunc  func(ctx *Context)
	Application *App
}

func (RootHandler) ServeHTTP

func (h RootHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Storage

type Storage interface {
	Get(string) string
	Set(string) string
	Delete(string) string
}

type StorageCmdItem

type StorageCmdItem struct {
	Op   int
	Arg1 interface{}
}

type StorageStat

type StorageStat struct {
	GetCount       int64
	SetCount       int64
	DeleteCount    int64
	HasCount       int64
	SaveIndexCount int64
}

Jump to

Keyboard shortcuts

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