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
- Variables
- func AddCommonServingOptions(serverBind, wwwRoot, charsetDynamic, charsetStatic, indices string, ...)
- func BuildMain(cfg *SiteBuilderCfg) int
- func MustDumpWebsite(w *Website)
- func RunServerMain(...)
- func SetDebug(truth bool)
- type HTTPResponseWrapper
- func (me *HTTPResponseWrapper) DebugContext(filename string, ctx map[string]interface{})
- func (me *HTTPResponseWrapper) NegotiateAndCallHandler()
- func (me *HTTPResponseWrapper) RegisterContentTypeHandler(contentType string, handlerFunc func(*HTTPResponseWrapper))
- func (me *HTTPResponseWrapper) Respond()
- func (me *HTTPResponseWrapper) RespondJSON()
- func (me *HTTPResponseWrapper) SetBody(o interface{})
- func (me *HTTPResponseWrapper) SetBodyBytes(body []byte)
- func (me *HTTPResponseWrapper) SetContentType(contentType string)
- func (me *HTTPResponseWrapper) SetError(err error)
- func (me *HTTPResponseWrapper) SetStatusCode(sc int)
- type SiteBuilderCfg
- type Website
- func (me *Website) Configure(serverBind, wwwRoot, charsetDynamic, charsetStatic, indices string, ...)
- func (me *Website) DebugNewRequest(simplatePath string, req *http.Request)
- func (me *Website) NewHTTPResponseWrapper(w http.ResponseWriter, req *http.Request) *HTTPResponseWrapper
- func (me *Website) RegisterSimplate(simplateType, siteRoot, requestPath string, handler http.HandlerFunc) *handlerFuncRegistration
- func (me *Website) RunServer() error
- func (me *Website) UpdateContextFromVirtualPaths(ctx *map[string]interface{}, requestPath, vPathString string)
- type WebsiteConfigurer
Constants ¶
const ( SimplateTypeRendered = "rendered" SimplateTypeStatic = "static" SimplateTypeNegotiated = "negotiated" SimplateTypeJson = "json" )
Variables ¶
var ( SiteIndexFilename = ".aspen-go-index.json" DefaultGenPackage = "aspen_go_gen" DefaultOutputGopath = "" )
var ( DefaultCharsetDynamic = "utf-8" DefaultCharsetStatic = DefaultCharsetDynamic DefaultContentType = "application/octet-stream" DefaultIndicesArray = []string{"index.html", "index.json", "index.txt"} DefaultIndices = strings.Join(DefaultIndicesArray, ",") DefaultConfig = &WebsiteConfigurer{} )
var (
InvalidTreeWalkerRoot = errors.New("Invalid tree walker root given")
)
var ( SimplateTypes = []string{ SimplateTypeJson, SimplateTypeNegotiated, SimplateTypeRendered, SimplateTypeStatic, } )
Functions ¶
func AddCommonServingOptions ¶
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 ¶
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 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 EnsureInitialized ¶
func EnsureInitialized() *Website
func MustLoadWebsite ¶
func MustLoadWebsite() *Website
func (*Website) DebugNewRequest ¶
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) UpdateContextFromVirtualPaths ¶
type WebsiteConfigurer ¶
type WebsiteConfigurer struct{}
func (*WebsiteConfigurer) Dump ¶
func (me *WebsiteConfigurer) Dump(website *Website, w io.Writer) error