File: README.md

package info (click to toggle)
golang-github-yosssi-ace-proxy 0.0~git20141007.0.ecd9b78-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 72 kB
  • ctags: 12
  • sloc: makefile: 8
file content (46 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Ace Proxy

[![wercker status](https://app.wercker.com/status/013ef8bb0794bdc457c3f3f766677bff/m "wercker status")](https://app.wercker.com/project/bykey/013ef8bb0794bdc457c3f3f766677bff)
[![GoDoc](http://godoc.org/github.com/yosssi/ace-proxy?status.svg)](http://godoc.org/github.com/yosssi/ace-proxy)
[![Coverage Status](https://img.shields.io/coveralls/yosssi/ace-proxy.svg)](https://coveralls.io/r/yosssi/ace-proxy?branch=master)

## Overview

Ace Proxy is a proxy for the Ace template engine. This proxy caches the options for the Ace template engine so that you don't have to specify them every time calling the Ace APIs.

## Usage

```go
package main

import (
	"net/http"

	"github.com/yosssi/ace"
	"github.com/yosssi/ace-proxy"
)

var p = proxy.New(&ace.Options{
	BaseDir:       "views",
	DynamicReload: true,
})

func handler(w http.ResponseWriter, r *http.Request) {
	tpl, err := p.Load("base", "", nil)

	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	if err := tpl.Execute(w, map[string]string{"Msg": "Hello Ace"}); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
}

func main() {
	http.HandleFunc("/", handler)
	http.ListenAndServe(":8080", nil)
}
```