http_render

package module
v0.0.0-...-442774c Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 11 Imported by: 1

README

http-render

HTTP Static and templates render Handler

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextKey contextKey
View Source
var ErrIsDir = errors.New("is directory")

Functions

func Ext

func Ext(name string) (ext string)

func HasExt

func HasExt(name string) bool

Types

type Asset

type Asset interface {
	Execute(r *Render, dst http.ResponseWriter) (err error)
}

type AssetFactory

type AssetFactory interface {
	Factory(name string) (exec Asset, err error)
}

type AssetFunc

type AssetFunc func(r *Render, dst http.ResponseWriter) (err error)

func (AssetFunc) Execute

func (this AssetFunc) Execute(r *Render, dst http.ResponseWriter) (err error)

type DirectoryAssetFactory

type DirectoryAssetFactory struct {
	Dir string
}

func (DirectoryAssetFactory) Factory

func (this DirectoryAssetFactory) Factory(name string) (exec Asset, err error)

func (DirectoryAssetFactory) GetDir

func (this DirectoryAssetFactory) GetDir() string

type FuncMap

type FuncMap map[string]interface{}

func (FuncMap) Merge

func (this FuncMap) Merge(m ...map[string]interface{}) FuncMap

func (*FuncMap) Update

func (this *FuncMap) Update(m ...map[string]interface{}) FuncMap

type Option

type Option func(r Render) Render

type Render

type Render struct {
	Request                *http.Request
	Status                 int
	Data                   interface{}
	FileNames              []string
	AssetFactory           AssetFactory
	DirectoryIndexDisabled bool
	TemplateFuncMap        FuncMap
}

func New

func New(opt ...Option) (r Render)

func (Render) MustRenderOrNotFound

func (this Render) MustRenderOrNotFound(w http.ResponseWriter)

func (Render) Option

func (this Render) Option(opt ...Option) Render

func (Render) Render

func (this Render) Render(dst http.ResponseWriter) (err error)

func (Render) RenderOrNotFound

func (this Render) RenderOrNotFound(w http.ResponseWriter) (err error)

func (Render) ServeHTTP

func (this Render) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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