cedar

package module
v0.0.0-...-f5a86df Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

README

Main

Update

Documentation

Index

Constants

View Source
const (
	LOCAL = iota
	SpruceLocal
	SPRUCE
)

Variables

View Source
var (
	Debug  = false
	Layout []string
	OUT    = "./view"
)

add new component view render

View Source
var (
	X  *spruce.Hash
	OP = -1
)

这里是session组件的存 默认是 启用 开源通过 r.StopSession关闭 现版本是只能启用 LOCAL模式

View Source
var FileType = map[string]string{"html": "text/html", "json": "application/json", "css": "text/css", "txt": "text/plain", "zip": "application/x-zip-compressed", "png": "image/png", "jpg": "image/jpeg"}

Functions

func ComplementHex

func ComplementHex(s string, x int) string

func CreateUUID

func CreateUUID(xtr []byte) []byte

func NewSession

func NewSession(types int)

func Random

func Random() []byte

func Sha1

func Sha1(b []byte) []byte

other function

func SplitString

func SplitString(str []byte, p []byte) []string

Types

type AutoRegister

type AutoRegister struct {
}

自动注册路由

type Core

type Core struct {
	PL      *Plugin
	Session Session
	// contains filtered or unexported fields
}

func (*Core) BasicAuth

func (co *Core) BasicAuth(args ...string) bool

2020/8/31 add basic auth component arg doubles include name and pass like this BasicAuth("user","pass","user2","pass2") , it's true BasicAuth("user","pass","user2") , it's false

func (*Core) Byte

func (co *Core) Byte(s string) []byte

func (*Core) Json

func (co *Core) Json() *json

func (*Core) Plugin

func (co *Core) Plugin(name string) plugin

在方法之中使用 插件

func (*Core) String

func (co *Core) String(b []byte) string

func (*Core) View

func (co *Core) View() *view

type DynamicRoute

type DynamicRoute struct {
	Name      string `dynamic:"name"`
	Path      string `dynamic:"path"`
	View      string `dynamic:"view"`
	Method    string `dynamic:"method"`
	Type      string `dynamic:"type"`
	ProxyPass string `dynamic:"proxy_pass"`
}

type GlobalFunc

type GlobalFunc struct {
	Name string
	Fn   func(w http.ResponseWriter, r *http.Request, co *Core) error
}

type Groups

type Groups struct {
	Tree *Trie
	Path string
}

func (*Groups) Connect

func (mux *Groups) Connect(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Delete

func (mux *Groups) Delete(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Get

func (mux *Groups) Get(path string, handlerFunc HandlerFunc, middleName ...string)

handFunc

func (*Groups) Group

func (mux *Groups) Group(path string, fn func(groups *Groups))

func (*Groups) Head

func (mux *Groups) Head(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Middleware

func (mux *Groups) Middleware(name string, fn func(w http.ResponseWriter, r *http.Request, co *Core) bool)

func (*Groups) Options

func (mux *Groups) Options(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Patch

func (mux *Groups) Patch(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Post

func (mux *Groups) Post(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Put

func (mux *Groups) Put(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Groups) Trace

func (mux *Groups) Trace(path string, handlerFunc HandlerFunc, middleName ...string)

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request, *Core)

type Plugin

type Plugin struct {
}

要求有自动注册插件到Core中去 插件名字 插件结构体 插件应该要继承 Core 结构体 并且重写 AutoStart 和 AutoBefore 方法 插件执行时间 应该分为2个阶段 一个是 系统启动 一个是 执行HandlerFunc之前

func (*Plugin) AutoBefore

func (pl *Plugin) AutoBefore(w http.ResponseWriter, r *http.Request, co *Core)
func (pl *Plugin)AutoStart() interface{}  {
	return nil
}

type SX

type SX struct {
	Key  string
	Body interface{}
}

type Session

type Session struct {
	sync.RWMutex
	Cookie string
}

func (Session) Flush

func (sn Session) Flush(key string) interface{}

func (Session) Get

func (sn Session) Get(key string) interface{}

func (Session) Set

func (sn Session) Set(key string, body interface{})

session function

type Son

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

func NewSon

func NewSon(method string, path string, handlerFunc HandlerFunc, handler http.Handler, deep int) *Son

type Trie

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

func NewRouter

func NewRouter(sessionSetting ...string) *Trie

func (*Trie) AutoRegister

func (mux *Trie) AutoRegister(auto interface{}, middleware ...string) *AutoRegister

func (*Trie) Connect

func (mux *Trie) Connect(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) Delete

func (mux *Trie) Delete(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) Dynamic

func (mux *Trie) Dynamic(ymlPath string, route *DynamicRoute)

func (*Trie) Find

func (mux *Trie) Find(key string, methods string) (string, HandlerFunc, http.Handler, string, string, bool)

func (*Trie) Get

func (mux *Trie) Get(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) GlobalFunc

func (mux *Trie) GlobalFunc(name string, fn func(w http.ResponseWriter, r *http.Request, co *Core) error)

func (*Trie) Group

func (mux *Trie) Group(path string, fn func(groups *Groups))

func (*Trie) Handler

func (mux *Trie) Handler(path string, handler http.Handler, middleName ...string)

func (*Trie) Head

func (mux *Trie) Head(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) Middle

func (mux *Trie) Middle(name string, fn func(w http.ResponseWriter, r *http.Request, co *Core) bool)

func (*Trie) Middleware

func (mux *Trie) Middleware(name string, fn func(w http.ResponseWriter, r *http.Request, co *Core) bool)

func (*Trie) Options

func (mux *Trie) Options(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) Patch

func (mux *Trie) Patch(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) Plugin

func (mux *Trie) Plugin(pluginStruct interface{})

直接从这里加载进插件池

func (*Trie) Post

func (mux *Trie) Post(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) Put

func (mux *Trie) Put(path string, handlerFunc HandlerFunc, middleName ...string)

func (*Trie) ServeHTTP

func (mux *Trie) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Trie) SetDebug

func (mux *Trie) SetDebug()

func (*Trie) SetLayout

func (mux *Trie) SetLayout(path ...string)

func (*Trie) SetView

func (mux *Trie) SetView(path string)

func (*Trie) StopSession

func (mux *Trie) StopSession()

func (*Trie) Trace

func (mux *Trie) Trace(path string, handlerFunc HandlerFunc, middleName ...string)

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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