Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("template not found") ErrPathTraversalBlocked = errors.New("path traversal blocked") )
View Source
var ( ErrNotAuthorized = errors.New("unauthorized") // ErrTemplateFailed is an error generated by the "fail" template function. ErrTemplateFailed = errors.New("") )
View Source
var ErrBadFuncRet = errors.New("wrong number of return values")
Functions ¶
Types ¶
type AuthService ¶
type AuthService interface { auth.Authorizer auth.CredentialsCreator }
type ControlledParams ¶
type ControlledParams struct { Ctx context.Context Phase Phase Auth AuthService // Headers are the HTTP response headers. They may only be modified // during PhasePrepare. Header http.Header // User is the user expanding the template. User *auth_model.User // Store is a place for funcs to keep stuff around, mostly between // phases. Each func should use its name as its index. Store map[string]interface{} }
type Credentials ¶
type Credentials struct {
Key, Secret string
}
type Expander ¶
type Expander interface { // Expand serves the template into w using the parameters specified // in params. If during expansion a template function fails, // returns an error without writing anything to w. (However if // expansion fails for other reasons, Expand may write to w!) Expand(w io.Writer, params *Params) error }
Expander is a template that may be expanded as requested by users.
func MakeExpander ¶
MakeExpander creates an expander for the text of tmpl.
type ExpanderMap ¶
type ExpanderMap struct {
// contains filtered or unexported fields
}
ExpanderMap reads and caches Expanders from a fs.FS. Currently, it provides no uncaching as it is only used with a prebuilt FS.
func NewExpanderMap ¶
func NewExpanderMap(fs fs.FS, cfg *config.Config, auth AuthService) *ExpanderMap
type Params ¶
type Params struct { // Controlled is the data visible to functions to control expansion. // It is _not_ directly visible to templates for expansion. Controlled *ControlledParams // Data is directly visible to templates for expansion, with no // authorization required. Data *UncontrolledData }
Params parametrizes a single template expansion.
type Service ¶
type Service interface {
Expand(ctx context.Context, w http.ResponseWriter, user *model.User, templateName string, query map[string]string) error
}
func NewService ¶
type UncontrolledData ¶
Click to show internal directories.
Click to hide internal directories.