aspen

package module
v0.0.0-...-ef072a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2013 License: MIT Imports: 24 Imported by: 0

README

Go port of the Aspen web framework (see here)

Build Status

Aspen in Go currently supports rendered, negotiated, and static Simplates as described here. The only template engine currently implemented is Go's standard library text/template.

Documentation

Overview

Go port of the Aspen web framework (http://aspen.io).

aspen currently supports rendered, negotiated, and static Simplates as described here: http://aspen.io/simplates/. The only template engine implemented is Go's standard library "text/template".

Index

Constants

View Source
const (
	SimplateTypeRendered   = "rendered"
	SimplateTypeStatic     = "static"
	SimplateTypeNegotiated = "negotiated"
	SimplateTypeJson       = "json"
)

Variables

View Source
var (
	SiteIndexFilename   = ".aspen-go-index.json"
	DefaultGenPackage   = "aspen_go_gen"
	DefaultOutputGopath = ""
)
View Source
var (
	DefaultCharsetDynamic = "utf-8"
	DefaultCharsetStatic  = DefaultCharsetDynamic
	DefaultContentType    = "application/octet-stream"
	DefaultIndicesArray   = []string{"index.html", "index.json", "index.txt"}
	DefaultIndices        = strings.Join(DefaultIndicesArray, ",")
	DefaultConfig         = &WebsiteConfigurer{}
)
View Source
var (
	InvalidTreeWalkerRoot = errors.New("Invalid tree walker root given")
)

Functions

func AddCommonServingOptions

func AddCommonServingOptions(serverBind,
	wwwRoot, charsetDynamic, charsetStatic, indices string,
	debug, listDirs bool)

func BuildMain

func BuildMain(cfg *SiteBuilderCfg) int

Build non-static simplates found in the given document root (SiteBuilderCfg.WwwRoot) into Go sources written to the src dir of a given GOPATH entry (SiteBuilderCfg.OutputGopath). The generated package (SiteBuilderCfg.GenPackage) will be used as the output source directory name and written as the package declaration for each generated Go source file. An http server source will also be written to a directory nested within the generated package.

Sources may be formatted via `gofmt` by setting the passed-in SiteBuilderCfg.Format to true. The generated package and http executable may be automatically compiled by setting the passed-in SiteBuilderCfg.Compile to true.

The generated server will support the following options, defaulted to the values passed to BuildMain:

       --www_root, -w: Filesystem path of the document publishing root
--network_address, -a: The IPv4 or IPv6 address to which the generated server
                       will bind by default
          --debug, -x: Print debugging output

func MustDumpWebsite

func MustDumpWebsite(w *Website)

func RunServerMain

func RunServerMain(wwwRoot, serverBind, packageName,
	charsetDynamic, charsetStatic, indices string, listDirs, debug bool)

func SetDebug

func SetDebug(truth bool)

Types

type HTTPResponseWrapper

type HTTPResponseWrapper struct {
	// contains filtered or unexported fields
}

func (*HTTPResponseWrapper) DebugContext

func (me *HTTPResponseWrapper) DebugContext(filename string, ctx map[string]interface{})

func (*HTTPResponseWrapper) NegotiateAndCallHandler

func (me *HTTPResponseWrapper) NegotiateAndCallHandler()

func (*HTTPResponseWrapper) RegisterContentTypeHandler

func (me *HTTPResponseWrapper) RegisterContentTypeHandler(contentType string,
	handlerFunc func(*HTTPResponseWrapper))

func (*HTTPResponseWrapper) Respond

func (me *HTTPResponseWrapper) Respond()

func (*HTTPResponseWrapper) RespondJSON

func (me *HTTPResponseWrapper) RespondJSON()

func (*HTTPResponseWrapper) SetBody

func (me *HTTPResponseWrapper) SetBody(o interface{})

func (*HTTPResponseWrapper) SetBodyBytes

func (me *HTTPResponseWrapper) SetBodyBytes(body []byte)

func (*HTTPResponseWrapper) SetContentType

func (me *HTTPResponseWrapper) SetContentType(contentType string)

func (*HTTPResponseWrapper) SetError

func (me *HTTPResponseWrapper) SetError(err error)

func (*HTTPResponseWrapper) SetStatusCode

func (me *HTTPResponseWrapper) SetStatusCode(sc int)

type SiteBuilderCfg

type SiteBuilderCfg struct {
	WwwRoot       string
	OutputGopath  string
	GenPackage    string
	GenServerBind string
	Format        bool
	MkOutDir      bool
	Compile       bool

	CharsetStatic  string
	CharsetDynamic string
	Indices        []string
	ListDirs       bool
	Debug          bool
}

type Website

type Website struct {
	PackageName string
	WwwRoot     string

	CharsetDynamic     string
	CharsetStatic      string
	DefaultContentType string
	Indices            []string
	ListDirs           bool
	Debug              bool
	// contains filtered or unexported fields
}

func DeclareWebsite

func DeclareWebsite(packageName string) *Website

func EnsureInitialized

func EnsureInitialized() *Website

func MustLoadWebsite

func MustLoadWebsite() *Website

func (*Website) Configure

func (me *Website) Configure(serverBind, wwwRoot, charsetDynamic,
	charsetStatic, indices string, debug, listDirs bool)

func (*Website) DebugNewRequest

func (me *Website) DebugNewRequest(simplatePath string, req *http.Request)

func (*Website) NewHTTPResponseWrapper

func (me *Website) NewHTTPResponseWrapper(w http.ResponseWriter, req *http.Request) *HTTPResponseWrapper

func (*Website) RegisterSimplate

func (me *Website) RegisterSimplate(simplateType, siteRoot, requestPath string,
	handler http.HandlerFunc) *handlerFuncRegistration

func (*Website) RunServer

func (me *Website) RunServer() error

func (*Website) UpdateContextFromVirtualPaths

func (me *Website) UpdateContextFromVirtualPaths(ctx *map[string]interface{},
	requestPath, vPathString string)

type WebsiteConfigurer

type WebsiteConfigurer struct{}

func (*WebsiteConfigurer) Dump

func (me *WebsiteConfigurer) Dump(website *Website, w io.Writer) error

func (*WebsiteConfigurer) Load

func (me *WebsiteConfigurer) Load(r io.Reader) (*Website, error)

func (*WebsiteConfigurer) MustDump

func (me *WebsiteConfigurer) MustDump(website *Website, w io.Writer)

func (*WebsiteConfigurer) MustLoad

func (me *WebsiteConfigurer) MustLoad(r io.Reader) *Website

Directories

Path Synopsis
Main entry point for Aspen.
Main entry point for Aspen.
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL