yogo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2016 License: MIT Imports: 22 Imported by: 0

README

#yogo A lightly go web api framework,target for develop friendly.

#Why write this? Just want to coding faster and konw how framework internal mechainsm work.

#Could others use this? Not recommended.This framework is under development,everythings could be change.

#Third Part Lib httprouter gorm httplib goconfig

#Reference gin beego

Documentation

Index

Constants

View Source
const (
	MIMEJSON = "application/json"
	MIMEHTML = "text/html"
)

Variables

View Source
var Conf tomlConfig
View Source
var IsLoadedConf = false
View Source
var IsLocal = false

Functions

func GetLocalIP

func GetLocalIP() string

e.g. 192.168.10.193

func GetUUID

func GetUUID() string

uuid singel to get

func HandleCheck

func HandleCheck(pairs ...string) func(c *Context)

func HandleGZIP

func HandleGZIP(c *Context)

func HandleHTML

func HandleHTML(c *Context)

func HandleJSON

func HandleJSON(c *Context)

中间件

func WaitForLoadConf

func WaitForLoadConf()

某些程序一定要在配置文件加载完以后才能运行

Types

type Context

type Context struct {
	W         http.ResponseWriter
	R         *http.Request
	PS        httprouter.Params
	StartTime time.Time

	UUID string
	// contains filtered or unexported fields
}

func (*Context) Byte

func (c *Context) Byte(b []byte) (int, error)

func (*Context) Exit

func (c *Context) Exit()

don't use rest of handle

func (*Context) FormValue

func (c *Context) FormValue(key string) string

func (*Context) Get

func (c *Context) Get(key string) (val interface{}, ok bool)

func (*Context) GetCookie

func (c *Context) GetCookie(key string) string

get cookies

func (*Context) GetIP

func (c *Context) GetIP() string

func (*Context) GetRawData

func (c *Context) GetRawData() string

func (*Context) JSON

func (c *Context) JSON(v map[string]interface{})

func (*Context) JSONAPI

func (c *Context) JSONAPI(code int, data interface{})

func (*Context) Load

func (c *Context) Load(p ...string)

func (*Context) LoadByData

func (c *Context) LoadByData(data interface{}, p ...string)

func (*Context) LoadByDataAndFunc

func (c *Context) LoadByDataAndFunc(p string, data interface{}, funcmap template.FuncMap)

func (*Context) Redirect

func (c *Context) Redirect(url string)

func (*Context) SaveFile

func (c *Context) SaveFile(filed, path string) (string, error)

文件助手 path 相对路径名 path最前面加/表示相对路径,不加表示绝对路径

func (*Context) Set

func (c *Context) Set(key string, val interface{})

func (*Context) SetCookie

func (c *Context) SetCookie(key, value string, maxAge int)

set cookies

func (*Context) String

func (c *Context) String(s string)

func (*Context) SuccessMap

func (c *Context) SuccessMap() (map[string]interface{}, map[string]interface{})

func (*Context) Template

func (c *Context) Template(data interface{})

解析自定文件 AdminArticles 会解析 view/admin/template.html + view/admin/articles.html两个文件

type FileHandler

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

静态文件处理Handler

func (*FileHandler) ServeHTTP

func (f *FileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GroupYoyo

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

func (*GroupYoyo) DELETE

func (g *GroupYoyo) DELETE(path string, handle ...Handle)

func (*GroupYoyo) GET

func (g *GroupYoyo) GET(path string, handle ...Handle)

func (*GroupYoyo) Group

func (g *GroupYoyo) Group(prefix string) *GroupYoyo

func (*GroupYoyo) HEAD

func (g *GroupYoyo) HEAD(path string, handle ...Handle)

func (*GroupYoyo) HanderFunc

func (g *GroupYoyo) HanderFunc(method, path string, hander http.HandlerFunc)

func (*GroupYoyo) Handle

func (g *GroupYoyo) Handle(method, path string, handle ...Handle)

func (*GroupYoyo) OPTIONS

func (g *GroupYoyo) OPTIONS(path string, handle ...Handle)

func (*GroupYoyo) PATCH

func (g *GroupYoyo) PATCH(path string, handle ...Handle)

func (*GroupYoyo) POST

func (g *GroupYoyo) POST(path string, handle ...Handle)

func (*GroupYoyo) PUT

func (g *GroupYoyo) PUT(path string, handle ...Handle)

func (*GroupYoyo) PreHandle

func (g *GroupYoyo) PreHandle(handle ...Handle)

func (*GroupYoyo) StaticFile

func (g *GroupYoyo) StaticFile(path string)

func (*GroupYoyo) TailHandle

func (g *GroupYoyo) TailHandle(handle ...Handle)

type GzipResponseWriter

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

func NewGzipResponseWriter

func NewGzipResponseWriter(rw http.ResponseWriter) *GzipResponseWriter

func (*GzipResponseWriter) Close

func (g *GzipResponseWriter) Close()

func (*GzipResponseWriter) Header

func (g *GzipResponseWriter) Header() http.Header

func (*GzipResponseWriter) Write

func (g *GzipResponseWriter) Write(b []byte) (int, error)

func (*GzipResponseWriter) WriteHeader

func (g *GzipResponseWriter) WriteHeader(code int)

type Handle

type Handle func(*Context)

type UUID

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

func NewUUID

func NewUUID() *UUID

func (*UUID) New

func (u *UUID) New() string

type Yoyo

type Yoyo struct {
	*GroupYoyo
	// contains filtered or unexported fields
}

func NewYoyo

func NewYoyo() *Yoyo

func (*Yoyo) Run

func (y *Yoyo) Run(addr string) error

func (*Yoyo) RunTLS

func (y *Yoyo) RunTLS(addr, crt, key string) error

func (*Yoyo) ServeHTTP

func (y *Yoyo) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package httplib is http helper.
Package httplib is http helper.
不需要创建实例对象,直接Write(v ...interface{})就好了
不需要创建实例对象,直接Write(v ...interface{})就好了
pools

Jump to

Keyboard shortcuts

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