Documentation ¶
Overview ¶
This package is a web framework that compatible with sdk http package. It also has a predefined 'standard' app engine server called GoEngine accessible through helper functions Handle, Server and so on.
Quick start:
import "github.com/mnhkahn/gogogo/app" import "github.com/mnhkahn/gogogo/logger" func Index(c *app.Context) error { c.WriteString("hello, world") return nil } app.Handle("/", &app.Got{Index}) l, err := net.Listen("tcp", ":"+port) if err != nil { logger.Errorf("Listen: %v", err) return } app.Serve(l)
For more information, goto godoc https://godoc.org/github.com/mnhkahn/gogogo/app.
A example site: http://cyeam.com.
Package app
Example ¶
// Package app_test package main import ( "github.com/mnhkahn/gogogo/app" "github.com/mnhkahn/gogogo/logger" "net" ) func Index(c *app.Context) error { c.WriteString("hello, world") return nil } func main() { app.Handle("/", &app.Got{Index}) l, err := net.Listen("tcp", ":1031") if err != nil { logger.Errorf("Listen: %v", err) return } app.Serve(l) }
Output:
Index ¶
- Constants
- Variables
- func AppInfo()
- func BasicAuthHandler(handler http.Handler, user, pwd string) http.Handler
- func DebugRouter(c *Context) error
- func DefaultString(key, def string) string
- func FreeContext(c *Context)
- func GetConfigAuth() (string, string, error)
- func GoAppHandler(c *Context) error
- func Handle(pattern string, h http.Handler)
- func InitAppConf() error
- func InitRouter()
- func Int(key string) int
- func LimitServe(limit int)
- func LogLevelHandler(c *Context) error
- func Serve(l net.Listener)
- func ServeMux(l net.Listener, handler http.Handler)
- func SetRecoverFunc(r func(w http.ResponseWriter, r *http.Request))
- func SetTimeout(d time.Duration)
- func StatHandler(c *Context) error
- func String(key string) string
- func Strings(key string) []string
- type Context
- func (c *Context) Debug() bool
- func (c *Context) Error(msg string)
- func (c *Context) GetBool(key string) (bool, error)
- func (c *Context) GetInt(key string, def ...int) (int, error)
- func (c *Context) GetInt64(key string, def ...int64) (int64, error)
- func (c *Context) GetString(key string, def ...string) string
- func (c *Context) GetStrings(key string) []string
- func (c *Context) GetUInt(key string, def ...uint) (uint, error)
- func (c *Context) GetUInt32(key string, def ...uint32) (uint32, error)
- func (c *Context) GetUInt64(key string, def ...uint64) (uint64, error)
- func (c *Context) GetUInt8(key string, def ...uint8) (uint8, error)
- func (c *Context) HTML(filenames []string, data interface{})
- func (c *Context) HTMLFunc(filenames []string, data interface{}, funcs template.FuncMap)
- func (c *Context) JSON(v interface{})
- func (c *Context) Query() url.Values
- func (c *Context) Serve(v interface{})
- func (c *Context) URL() string
- func (c *Context) WriteBytes(raw []byte)
- func (c *Context) WriteString(str string)
- type Engine
- type Got
- type Handler
- type Stat
Examples ¶
Constants ¶
const DefaultLimit = 20
DefaultLimit ...
Variables ¶
var ( VERSION = "N/A" BRANCH = "N/A" BUILD = "N/A" )
go build version, use build flags to assign value. -ldflags='-X "github.com/mnhkahn/gogogo/app.VERSION=$(VERSION)" -X "github.com/mnhkahn/gogogo/app.BRANCH=$(branch)" -X "github.com/mnhkahn/gogogo/app.BUILD=$(DATE)"'
var DefaultHandler = NewHandler()
DefaultHandler ...
var (
ErrConfNotInit = errors.New("appconfig is not init, forgot to call InitAppConf()? ")
)
var GoEngine = NewEngine()
Default predefined engine
Functions ¶
func AppInfo ¶
func AppInfo()
AppInfo prints app info with git version, git branch, build date and go version.
func BasicAuthHandler ¶ added in v1.0.9
BasicAuthHandler ...
func GoAppHandler ¶
GoAppHandler is a handler to show debug information.
func LogLevelHandler ¶
LogLevelHandler is a handler to set log level for StdLogger.
func SetRecoverFunc ¶
func SetRecoverFunc(r func(w http.ResponseWriter, r *http.Request))
SetRecoverFunc ...
func StatHandler ¶ added in v1.0.9
Types ¶
type Context ¶
Context ...
func AllocContext ¶
func AllocContext(rw http.ResponseWriter, req *http.Request) *Context
AllocContext ...
func NewContext ¶
func NewContext(rw http.ResponseWriter, req *http.Request) *Context
NewContext ...
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package example
|
Package example |
handler
|
|
func_to_handler
Package func_to_handler ...
|
Package func_to_handler ... |