mvc

package
v1.248.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTemplate

func ParseTemplate(fs fs.FS, pattern string) *template.Template

ParseTemplate for mvc.

func Register

func Register(mu *http.ServeMux)

Register for mvc.

func Route

func Route[Res any](path string, view *View, controller Controller[Res])

Route the template with the path.

func WriteError added in v1.247.0

func WriteError(ctx context.Context, view *View, res http.ResponseWriter, err error)

WriteError for mvc.

Types

type Controller

type Controller[Model any] func(ctx context.Context, req *http.Request, res http.ResponseWriter) (*Model, error)

Controller for mvc.

var NoController Controller[any]

NoController for mvc.

type View

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

View used for routes.

func NewSuccessView added in v1.248.0

func NewSuccessView(template *template.Template) *View

NewSuccessView for routes in mvc.

func NewView

func NewView(success, failure *template.Template) *View

NewView for routes in mvc.

func (*View) ExecuteFailure

func (t *View) ExecuteFailure(wr io.Writer, err error) error

ExecuteFailure for template.

func (*View) ExecuteSuccess

func (t *View) ExecuteSuccess(wr io.Writer, data any) error

ExecuteSuccess for template.

Jump to

Keyboard shortcuts

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