示例#1
0
文件: copter.go 项目: plirr/copter
func New(options *Options) *Copter {
	copter := &Copter{}
	if options.IsDevelopment {
		pongo2.DefaultSet.Debug = true
	}

	if options.PoolSize == 0 {
		copter.pool = pool.NewBufferPool(100)
	} else {
		copter.pool = pool.NewBufferPool(options.PoolSize)
	}

	if len(options.Extensions) == 0 {
		options.Extensions = []string{".tpl", ".html"}
	}

	if options.Directory == "" {
		options.Directory = "./"
	}

	copter.options = options
	copter.Set = pongo2.DefaultSet
	copter.Set.SetBaseDirectory(options.Directory)
	copter.compileTemplates()
	return copter
}
示例#2
0
文件: ace.go 项目: leobcn/ace
//SetPoolSize of buffer
func (a *Ace) SetPoolSize(poolSize int) {
	bufPool = pool.NewBufferPool(poolSize)
}
示例#3
0
文件: ace.go 项目: leobcn/ace
package ace

import (
	"github.com/julienschmidt/httprouter"
	"github.com/plimble/utils/pool"
	"net/http"
	"sync"
)

var bufPool = pool.NewBufferPool(100)

type Ace struct {
	*Router
	httprouter   *httprouter.Router
	pool         sync.Pool
	render       Renderer
	panicFunc    PanicHandler
	notfoundFunc HandlerFunc
}

type PanicHandler func(c *C, rcv interface{})
type HandlerFunc func(c *C)

func GetPool() *pool.BufferPool {
	return bufPool
}

//New server
func New() *Ace {
	a := &Ace{}
	a.Router = &Router{