Documentation
¶
Overview ¶
Serving resource from zip file appended to Go executable (this enables on file deploy).
Making it happen:
- Add code to serve resources (see example below)
- Compile your executable
- Run "nrsc /path/to/exe /path/to/resources"
- Deploy
Example code:
package main
import (
"fmt"
"net/http"
"os"
"bitbucket.org/tebeka/nrsc"
)
type params struct {
Number int
}
func indexHandler(w http.ResponseWriter, req *http.Request) {
t, err := nrsc.LoadTemplates(nil, "t.html")
if err != nil {
http.NotFound(w, req)
}
if err = t.Execute(w, params{7}); err != nil {
http.NotFound(w, req)
}
}
func main() {
nrsc.Handle("/static/")
nrsc.Mask(".tmpl$")
http.HandleFunc("/", indexHandler)
if err := http.ListenAndServe(":8080", nil); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}
Index ¶
Constants ¶
View Source
const (
Version = "0.4.1"
)
Variables ¶
View Source
var ResourceMap map[string]Resource = nil
Functions ¶
func Initialize ¶
func Initialize() error
func LoadTemplates ¶
LoadTemplates loads named templates from resources. If the argument "t" is nil, it is created from the first resource.
Types ¶
Click to show internal directories.
Click to hide internal directories.