hiro

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT, MIT Imports: 48 Imported by: 21

Documentation

Index

Constants

View Source
const (
	FlashSuccess = "success"
	FlashWarning = "warning"
	FlashError   = "error"
)
View Source
const (
	Action = "action"
	Main   = "main"
)
View Source
const (
	Version = "0.2.3"
)

Variables

View Source
var (
	ErrorInvalidDatabase = errors.New("invalid database")
	ErrorNoPtr           = errors.New("target is not a pointer")
	ErrorMismatchType    = errors.New("target is not equal with value type")
)

Functions

func TestRoute

func TestRoute(param TestRouteParam) *httptest.ResponseRecorder

Types

type Component

type Component struct {
	Ctx `json:"-"`
}

func (Component) On added in v0.1.4

func (c Component) On(trigger string) *Interaction

type Ctx

type Ctx interface {
	Auth(dbname ...string) auth.Manager
	Cache() cache.Client
	Config() config.Config
	Continue() error
	Cookie() cookie.Cookie
	Create() Factory
	Csrf() csrf.Csrf
	DB(dbname ...string) *esquel.DB
	Dev() Dev
	Email() mailer.Mailer
	Export() Export
	Files() filesystem.Client
	Flash() Flash
	Generate() Generator
	Lang() Lang
	Log() logger.Log
	Page() Page
	Parse() parser.Parse
	Request() Request
	Response() Response
	State() State
	Translate(key string, args ...map[string]any) string
	Ws(name string) *Ws
}

func TestCtx

func TestCtx(param TestCtxParam) Ctx

type Dev added in v0.1.8

type Dev interface {
	Debug(values ...any) error
	MustDebug(values ...any)
}

type Export

type Export interface {
	Csv() exporter.Csv
	Excel() exporter.Excel
	Pdf() exporter.Pdf
}

type Factory

type Factory interface {
	Component(ct MandatoryComponent) gox.Node
	Defer(link string, nodes ...gox.Node) gox.Node
	Form(fields ...*form.FieldBuilder) *form.Builder
}

type Flash

type Flash interface {
	Get() ([]Message, error)
	Success(title, value string) error
	Warning(title, value string) error
	Error(title, value string) error

	MustGet() []Message
	MustSuccess(title, value string)
	MustWarning(title, value string)
	MustError(title, value string)
}

type Generator

type Generator interface {
	Assets(name string) gox.Node
	Action(name string, args ...Map) string
	Current(qpm ...Map) string
	Csrf(name string) gox.Node
	Link(name string, args ...Map) string
	PublicUrl(path string) string
	Query(args Map) string
	SwitchLang(langCode string) string
}

type Handler

type Handler func(c Ctx) error

type Hiro added in v0.1.1

type Hiro interface {
	Router
	Log(handler logger.Handler) Hiro
	DynamicHandler(handler Handler) Hiro
	Layout() LayoutManager
	Run(address string)
	Mux() *http.ServeMux
	Plugin(plugin Plugin) Hiro
}

func New

func New(cfg config.Config) Hiro

type Interaction added in v0.1.4

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

func (*Interaction) Action added in v0.1.4

func (i *Interaction) Action(action string, args ...Map) *Interaction

func (*Interaction) Append added in v0.1.4

func (i *Interaction) Append(target string) *Interaction

func (*Interaction) Delete added in v0.1.4

func (i *Interaction) Delete(target string) *Interaction

func (*Interaction) Node added in v0.1.4

func (i *Interaction) Node() gox.Node

func (*Interaction) Prepend added in v0.1.4

func (i *Interaction) Prepend(target string) *Interaction

func (*Interaction) Replace added in v0.1.4

func (i *Interaction) Replace(target string) *Interaction

func (*Interaction) With added in v0.1.4

func (i *Interaction) With(values Map) *Interaction

type Intercept

type Intercept interface {
	Error() error
	Status() int
}

type Lang

type Lang interface {
	Main() string
	Exists() bool
	Current() string
}

type LayoutManager

type LayoutManager interface {
	Add(name string, layout layoutFactory) LayoutManager
}

type MandatoryComponent

type MandatoryComponent interface {
	gox.Node
	Name() string
	Mount()
}

type Map

type Map map[string]any

func (Map) Merge

func (m Map) Merge(mm Map) Map

type Message

type Message struct {
	Type  string `json:"type"`
	Title string `json:"title"`
	Value string `json:"value"`
}

type Page

type Page interface {
	Get() PageGetter
	Set() PageSetter
}

type PageGetter

type PageGetter interface {
	Title() string
	Description() string
	Keywords() string
	Metas() [][2]string
}

type PageSetter

type PageSetter interface {
	Title(title string) PageSetter
	Description(description string) PageSetter
	Keywords(keywords ...string) PageSetter
	Meta(name, content string) PageSetter
}

type Plugin

type Plugin struct {
	Name    string
	Locales map[string]map[string]string
}

type Request

type Request interface {
	Action() string
	ContentType() string
	Form() url.Values
	Header() http.Header
	Host() string
	Ip() string
	Is() RequestIs
	Method() string
	Name() string
	Origin() string
	Parsed() Map
	Path() string
	PathValue(key string, defaultValue ...string) string
	QueryParam(key string, defaultValue ...string) string
	QueryMap() Map
	PathMap() Map
	Protocol() string
	Raw() *http.Request
	UserAgent() string
}

type RequestIs

type RequestIs interface {
	Get() bool
	Post() bool
	Put() bool
	Patch() bool
	Delete() bool
	Action(actionName ...string) bool
	Active(routeName string) bool
	Hx() bool
	Options() bool
	Head() bool
	Connect() bool
	Trace() bool
	Form() bool
}

type Response

type Response interface {
	sender.ExtendableSend
	Status(statusCode int) Response
	Refresh() error
	Render(nodes ...gox.Node) error
	Intercept() Intercept
}

type Route

type Route struct {
	Lang       string
	Path       string
	Name       string
	Layout     layoutFactory
	Matcher    *regexp.Regexp
	Methods    []string
	Firewall   []firewall.Firewall
	PathValues []string
	Ws         socketer.Ws
	Components map[string]MandatoryComponent
}

type RouteConfig

type RouteConfig struct {
	Type  int
	Value any
}

func Layout

func Layout(name string) RouteConfig

func Method

func Method(method ...string) RouteConfig

func Name

func Name(name string) RouteConfig

type Router

type Router interface {
	Use(handler ...Handler) Router
	Static(path, dir string) Router
	Route(path any, handler Handler, config ...RouteConfig) Router
	Ws(path any, config ...RouteConfig) Router
	Group(path any, name ...string) Router
}

type Slice

type Slice []Map

type State

type State interface {
	Token() string
	Get(key string, target any, preserve ...bool) error
	Save(key string, value any) error
	Delete(key string) error

	MustGet(key string, target any, preserve ...bool)
	MustSave(key string, value any)
	MustDelete(key string)
}

type TestCtxParam

type TestCtxParam struct {
	Config         config.Config
	Request        *http.Request
	ResponseWriter http.ResponseWriter
	MatchedRoute   *Route
	Routes         *[]*Route
}

type TestRouteParam

type TestRouteParam struct {
	Config  *config.Config
	Method  string
	Path    string
	TempDir string
	Body    io.Reader
	Handler func(c Ctx) error
}

type Ws added in v0.2.1

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

func (*Ws) Broadcast added in v0.2.1

func (w *Ws) Broadcast(nodes ...gox.Node) error

func (*Ws) Client added in v0.2.1

func (w *Ws) Client(ids ...string) *Ws

func (*Ws) MustBroadcast added in v0.2.1

func (w *Ws) MustBroadcast(nodes ...gox.Node)

func (*Ws) MustSend added in v0.2.1

func (w *Ws) MustSend(nodes ...gox.Node)

func (*Ws) Send added in v0.2.1

func (w *Ws) Send(nodes ...gox.Node) error

Jump to

Keyboard shortcuts

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