Beispiel #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
}
Beispiel #2
0
Datei: ace.go Projekt: leobcn/ace
//SetPoolSize of buffer
func (a *Ace) SetPoolSize(poolSize int) {
	bufPool = pool.NewBufferPool(poolSize)
}
Beispiel #3
0
Datei: ace.go Projekt: 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{