예제 #1
0
func serveConnection(serverName string, secure bool, handler web.Handler, netConn net.Conn) {
	br := bufio.NewReader(netConn)
	for {
		c := conn{
			serverName: serverName,
			secure:     secure,
			netConn:    netConn,
			br:         br}
		if err := c.prepare(); err != nil {
			if err != os.EOF {
				log.Stderr("twister/sever: prepare failed", err)
			}
			break
		}
		handler.ServeWeb(c.req)
		if c.hijacked {
			return
		}
		if err := c.finish(); err != nil {
			log.Stderr("twister/sever: finish failed", err)
			break
		}
		if c.closeAfterResponse {
			break
		}
	}
	netConn.Close()
}
예제 #2
0
파일: handlers.go 프로젝트: BradMuller/lwb
// DebugFilter does various things (like reloading templates on each request if
// in debug mode).
func DebugFilter(enabled bool, config *lwb.BlogConfig, handler web.Handler) web.Handler {
	if !enabled {
		return handler
	}

	return web.HandlerFunc(func(req *web.Request) {
		ReloadTemplates(config)
		handler.ServeWeb(req)
	})
}