mvc

package
v1.404.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: MIT Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mu *http.ServeMux, vi *Views)

Register for mvc.

func Route

func Route[Model any](path string, controller Controller[Model]) bool

Route the path with controller for mvc.

func Static added in v1.402.0

func Static(path, name string) bool

Static file name to be served via path.

Types

type Controller

type Controller[Model any] func(ctx context.Context) (View, *Model, error)

Controller for mvc.

type Patterns added in v1.257.0

type Patterns []string

Patterns to render views.

type View

type View string

View to render.

func (View) Render added in v1.402.0

func (v View) Render(ctx context.Context, res http.ResponseWriter, model any)

Render the view.

type Views added in v1.257.0

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

View for mvc.

func NewViews added in v1.257.0

func NewViews(params ViewsParams) *Views

NewView from fs with patterns.

func (*Views) IsValid added in v1.364.0

func (v *Views) IsValid() bool

IsValid verifies that ut has an fs and template.

type ViewsParams added in v1.257.0

type ViewsParams struct {
	fx.In

	FS       fs.FS    `optional:"true"`
	Patterns Patterns `optional:"true"`
}

ViewsParams for mvc.

func (ViewsParams) IsValid added in v1.364.0

func (p ViewsParams) IsValid() bool

IsValid verifies the params are present.

Jump to

Keyboard shortcuts

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