Esempio n. 1
0
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
}
Esempio n. 2
0
File: ace.go Progetto: leobcn/ace
//SetPoolSize of buffer
func (a *Ace) SetPoolSize(poolSize int) {
	bufPool = pool.NewBufferPool(poolSize)
}
Esempio n. 3
0
File: ace.go Progetto: 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{