kit

package
v0.0.0-...-e7f8e0a Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env() string

func Getenv

func Getenv(name string, def string) string

func Handler

func Handler(h HandlerFunc) http.HandlerFunc

func IsDevelopment

func IsDevelopment() bool

func IsProduction

func IsProduction() bool

func Setup

func Setup()

initialize the store here so the environment variables are already initialized. Calling NewCookieStore() from outside of a function scope won't work.

func UseErrorHandler

func UseErrorHandler(h ErrorHandlerFunc)

func WithAuthentication

func WithAuthentication(config AuthenticationConfig, strict bool) func(http.Handler) http.Handler

Types

type Auth

type Auth interface {
	Check() bool
}

type AuthKey

type AuthKey struct{}

type AuthenticationConfig

type AuthenticationConfig struct {
	AuthFunc    func(*Kit) (Auth, error)
	RedirectURL string
}

type DefaultAuth

type DefaultAuth struct{}

func (DefaultAuth) Check

func (DefaultAuth) Check() bool

type ErrorHandlerFunc

type ErrorHandlerFunc func(kit *Kit, err error)

type HandlerFunc

type HandlerFunc func(kit *Kit) error

type Kit

type Kit struct {
	Response http.ResponseWriter
	Request  *http.Request
}

func (*Kit) Auth

func (kit *Kit) Auth() Auth

func (*Kit) Bytes

func (kit *Kit) Bytes(status int, b []byte) error

func (*Kit) FormValue

func (kit *Kit) FormValue(name string) string

func (*Kit) GetSession

func (kit *Kit) GetSession(name string) *sessions.Session

GetSession return a session by its name. GetSession always returns a session even if it does not exist.

func (*Kit) Getenv

func (kit *Kit) Getenv(name string, def string) string

func (*Kit) JSON

func (kit *Kit) JSON(status int, v any) error

func (*Kit) Redirect

func (kit *Kit) Redirect(status int, url string) error

Redirect with HTMX support.

func (*Kit) Render

func (kit *Kit) Render(c templ.Component) error

func (*Kit) Text

func (kit *Kit) Text(status int, msg string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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