mvc

package
v1.246.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 7 Imported by: 5

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.

Types

type Controller

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

Controller for mvc.

type View

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

View used for routes.

func NewView

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

NewView for routes in mvc.

func (*View) ExecuteFailure

func (t *View) ExecuteFailure(wr io.Writer, data any) 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