core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisableLogger bool
View Source
var Log = &Logger{Level: DEBUG} // default

Functions

func LoggerWrap

func LoggerWrap(c *Context, handlers []Handler)

Types

type Context

type Context struct {
	Ctx    *fasthttp.RequestCtx
	Cache  *cache.Engine
	Pubsub *pubsub.Engine
	Queue  *queue.Engine
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx *fasthttp.RequestCtx, cache *cache.Engine, handlers []Handler) *Context

func (*Context) Abort

func (c *Context) Abort()

func (*Context) Aborted

func (c *Context) Aborted() bool

func (*Context) Async

func (c *Context) Async(fn func())

Async menjalankan fungsi dalam goroutine tanpa block

func (*Context) BindJSON

func (c *Context) BindJSON(dest any) error

Body binds JSON body to a struct

func (*Context) GetSession

func (c *Context) GetSession(key string) any

func (*Context) Header

func (c *Context) Header(key string) string

func (*Context) JSON

func (c *Context) JSON(status int, data any)

JSON writes a JSON response

func (*Context) MustPubsub

func (c *Context) MustPubsub() *pubsub.Engine

func (*Context) MustQueue

func (c *Context) MustQueue() *queue.Engine

func (*Context) Next

func (c *Context) Next()

func (*Context) Parallel

func (c *Context) Parallel(funcs ...func())

Parallel menjalankan banyak fungsi lalu menunggu semuanya selesai

func (*Context) Param

func (c *Context) Param(key string) string

Param returns a URL parameter (from user-defined routing system)

func (*Context) Query

func (c *Context) Query(key string) string

Query returns a query parameter

func (*Context) SetPubsub

func (c *Context) SetPubsub(p *pubsub.Engine)

func (*Context) SetQueue

func (c *Context) SetQueue(q *queue.Engine)

func (*Context) SetSession

func (c *Context) SetSession(key string, value any)

func (*Context) Text

func (c *Context) Text(code int, msg string)

Text writes a plain text response

type EngineContext

type EngineContext struct {
	Pubsub *pubsub.Engine
	Queue  *queue.Engine
}

type Group

type Group struct {
	Prefix     string
	Parent     RouterApp
	Middleware []Handler
}

func (*Group) Add

func (g *Group) Add(methods []string, path string, h Handler, hs ...Handler) *Route

func (*Group) All

func (g *Group) All(path string, h Handler, hs ...Handler) *Route

func (*Group) Connect

func (g *Group) Connect(path string, h Handler, hs ...Handler) *Route

func (*Group) Delete

func (g *Group) Delete(path string, h Handler, hs ...Handler) *Route

func (*Group) Get

func (g *Group) Get(path string, h Handler, hs ...Handler) *Route

func (*Group) Group

func (g *Group) Group(prefix string, handlers ...Handler) Router

func (*Group) Head

func (g *Group) Head(path string, h Handler, hs ...Handler) *Route

func (*Group) Options

func (g *Group) Options(path string, h Handler, hs ...Handler) *Route

func (*Group) Patch

func (g *Group) Patch(path string, h Handler, hs ...Handler) *Route

func (*Group) Post

func (g *Group) Post(path string, h Handler, hs ...Handler) *Route

func (*Group) Put

func (g *Group) Put(path string, h Handler, hs ...Handler) *Route

func (*Group) Route

func (g *Group) Route(path string) *Route

func (*Group) Trace

func (g *Group) Trace(path string, h Handler, hs ...Handler) *Route

func (*Group) Use

func (g *Group) Use(args ...any) Router

type Handler

type Handler func(*Context)

type LogLevel

type LogLevel string
const (
	DEBUG LogLevel = "DEBUG"
	INFO  LogLevel = "INFO"
	WARN  LogLevel = "WARN"
	ERROR LogLevel = "ERROR"
)

type Logger

type Logger struct {
	Level LogLevel
}

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

type Route

type Route struct {
	Method   string
	Path     string
	Name     string
	Handlers []Handler
	Options  routeOptions
	// contains filtered or unexported fields
}

func AddRoute

func AddRoute(app RouterApp, methods []string, path string, handler Handler, handlers ...Handler) *Route

func (*Route) Cache

func (r *Route) Cache(ttl time.Duration) *Route

func (*Route) Named

func (r *Route) Named(name string) *Route

func (*Route) NoCache

func (r *Route) NoCache() *Route

type Router

type Router interface {
	Use(args ...any) Router

	Get(path string, handler Handler, handlers ...Handler) *Route
	Head(path string, handler Handler, handlers ...Handler) *Route
	Post(path string, handler Handler, handlers ...Handler) *Route
	Put(path string, handler Handler, handlers ...Handler) *Route
	Delete(path string, handler Handler, handlers ...Handler) *Route
	Connect(path string, handler Handler, handlers ...Handler) *Route
	Options(path string, handler Handler, handlers ...Handler) *Route
	Trace(path string, handler Handler, handlers ...Handler) *Route
	Patch(path string, handler Handler, handlers ...Handler) *Route

	Add(methods []string, path string, handler Handler, handlers ...Handler) *Route
	All(path string, handler Handler, handlers ...Handler) *Route

	Group(prefix string, handlers ...Handler) Router
	Route(path string) *Route
}

type RouterApp

type RouterApp interface {
	GetRoutes() []*Route
	SetRoutes([]*Route)
	GetMiddleware() []Handler
	GetRouter() *router.Router
	WrapHandlers([]Handler) fasthttp.RequestHandler
}

Jump to

Keyboard shortcuts

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