| env | ||
| logger | ||
| scheduler | ||
| template/components | ||
| testingdata | ||
| .gitignore | ||
| cache.go | ||
| cache_test.go | ||
| config.go | ||
| consts.go | ||
| context.go | ||
| context_test.go | ||
| controller.go | ||
| cookies.go | ||
| cookies_test.go | ||
| core.go | ||
| core_test.go | ||
| event-job.go | ||
| event.go | ||
| events-manager.go | ||
| events-manager_test.go | ||
| go.mod | ||
| go.sum | ||
| graph.go | ||
| hashing.go | ||
| hashing_test.go | ||
| hook.go | ||
| hooks.go | ||
| hooks_test.go | ||
| jwt.go | ||
| jwt_test.go | ||
| LICENSE | ||
| mailer.go | ||
| queue.go | ||
| README.md | ||
| request.go | ||
| response.go | ||
| response_test.go | ||
| router.go | ||
| router_test.go | ||
| scheduler.go | ||
| session.go | ||
| session_test.go | ||
| templates.go | ||
| templates_test.go | ||
| testing-config.go | ||
| validator.go | ||
| validator_test.go | ||
Goffee Core
The core library of the Goffee framework. It provides the building blocks used by every
Goffee application: routing, the request Context and Response, hooks, events, JWT,
sessions/cookies, cache, mailer, validation, templating, queues and the DB-backed scheduler.
If you are going to develop an application, the way to do so is through the Cup project. Check out the Goffee Cup repository.
Main concepts
App
core.App is the application container. core.New() creates it, Bootstrap() initializes
the logger, router and events manager, and Run() starts the HTTP server. Configuration is
applied through the Set...Config methods (SetRequestConfig, SetGormConfig,
SetCacheConfig, SetEnvFileConfig, ...).
Router and controllers
Routes are registered on the singleton returned by core.ResolveRouter(). Each route maps
a method + path to a Controller (a func(*core.Context) *core.Response) and an optional
list of Hooks.
router := core.ResolveRouter()
router.Get("/users/:id", showUser, hooks.AuthCheck)
Context and Response
A *core.Context carries the request and exposes helpers: GetRequestParam, GetPathParam,
GetHeader, GetRequesBodyStruct, GetUploadedFile, MoveFile, CopyFile,
MapToJson, CastToString/CastToInt/CastToFloat, GetBaseDirPath, and service
accessors like GetLogger, GetGorm, GetCache, GetJWT, GetMailer, GetSession,
GetQueueClient and GetEventsManager. c.Response builds the reply with
Json, Text, HTML, Template, BufferFile, Redirect, etc.
Packages
| Package | Description |
|---|---|
core |
The framework itself: app, router, context, response, hooks, events, jwt, session, cache, mailer, validator, templates, queues and scheduler wiring. |
core/env |
Helpers to read environment variables with defaults. |
core/logger |
Logging drivers (LogFileDriver, LogNullDriver, ...). |
core/scheduler |
The DB-backed task scheduler: Store, QueueItem, ProcessedItem, SchedulerMeta. |
core/template/components |
Reusable template components (e.g. PageCard). |
Background processing
- Queues (asynq): see
core.Queuemux/QueueConfig. - Scheduler: a lightweight DB-backed runner with priorities, concurrent threads and a
global semaphore kill-switch. Use
core.Schedulermuxto register task handlers, thenscheduler.NewStore(core.ResolveGorm())andSetStorebeforeRunScheduler.
License
MIT-style license. See the LICENSE file for details.