Help us shape the future of Go! Take the 2026 Go Developer Survey

decide

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package decide provides the constructors for app.Decision values returned from Policy.Decide implementations. Lives in a subpackage (rather than under app directly) so call sites read like `decide.Block(403, "no")` without shadowing common variable names ("block", "redirect") that authors reach for.

import (
    "github.com/DonaldMurillo/gofastr/core-ui/app"
    "github.com/DonaldMurillo/gofastr/core-ui/app/decide"
)

pol := app.PolicyFunc(func(ctx context.Context) app.Decision {
    if authed(ctx) { return decide.Allow() }
    return decide.Redirect("/login")
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allow

func Allow() app.Decision

Allow returns the "let the request proceed" Decision.

func Block

func Block(status int, message string) app.Decision

Block returns a Decision that aborts with status (e.g. 401, 403, 404). Message is optional human-readable text.

func Redirect

func Redirect(url string) app.Decision

Redirect returns a Decision that redirects the request to url. Hosts typically use HTTP 303 See Other so POST→Redirect→GET works.

func RenderAlt

func RenderAlt(factory func() component.Component) app.Decision

RenderAlt returns a Decision that renders an alt component in place of the screen's own. factory MUST return a FRESH instance per call — the framework invokes it once per request and the returned component is then mutated by SetParams / Inject / Load under the screen lock. Sharing a singleton is a cross-user data leak.

Types

This section is empty.

Jump to

Keyboard shortcuts

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