mvc

package
v2.126.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete[Model any](pattern string, controller Controller[Model]) bool

Delete method for mvc.

func Get

func Get[Model any](pattern string, controller Controller[Model]) bool

Get method for mvc.

func IsDefined

func IsDefined() bool

IsDefined for mvc.

func NewFunctionMap

func NewFunctionMap(params FunctionMapParams) sprout.FunctionMap

NewFunctionMap for sprout. List of registries can be found at https://docs.atom.codes/sprout/registries/list-of-all-registries

func NewViewPair

func NewViewPair(name string) (*View, *View)

NewViewPair returns a pair of full and partial view.

func Patch

func Patch[Model any](pattern string, controller Controller[Model]) bool

Patch method for mvc.

func Post

func Post[Model any](pattern string, controller Controller[Model]) bool

Post method for mvc.

func Put

func Put[Model any](pattern string, controller Controller[Model]) bool

Put method for mvc.

func Register

func Register(params RegisterParams)

Register for mvc.

func Route

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

Route the path with controller for mvc.

func StaticFile

func StaticFile(pattern, name string) bool

StaticFile to be served via path.

func StaticPathValue

func StaticPathValue(pattern, value, prefix string) bool

StaticPathValue to be served from a dedicated path value.

Types

type Controller

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

Controller for mvc.

type FunctionMapParams

type FunctionMapParams struct {
	di.In
	Logger     *slog.Logger
	Registries []sprout.Registry `optional:"true"`
}

FunctionMapParams for sprout.

type Layout

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

Layout is the main template that is used for all other templates.

func NewLayout

func NewLayout(full, partial string) *Layout

NewLayout defines a full and partial layout.

func (*Layout) Full

func (l *Layout) Full() string

Full of the layout.

func (*Layout) FullName

func (l *Layout) FullName() string

FullName of the layout.

func (*Layout) IsValid

func (l *Layout) IsValid() bool

IsValid the layout.

func (*Layout) Partial

func (l *Layout) Partial() string

Partial of the layout.

func (*Layout) PartialName

func (l *Layout) PartialName() string

PartialName of the layout.

type RegisterParams

type RegisterParams struct {
	di.In
	Mux         *http.ServeMux
	FunctionMap sprout.FunctionMap
	FileSystem  fs.FS   `optional:"true"`
	Layout      *Layout `optional:"true"`
}

RegisterParams for mvc.

type Template

type Template struct {
	Meta  meta.Map
	Model any
}

Template that is rendered by the view.

type View

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

View to render.

func NewFullView

func NewFullView(name string) *View

NewFullView to render.

func NewPartialView

func NewPartialView(name string) *View

NewPartialView to render.

func (*View) Render

func (v *View) Render(ctx context.Context, model any)

Render the view.

Jump to

Keyboard shortcuts

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