diff options
| author | Bobby <[email protected]> | 2026-03-07 15:09:42 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-07 15:09:42 +0530 |
| commit | 8f8d41413ff775b6d721059783a0e2de4f90f50c (patch) | |
| tree | 40923d049ee7df8b0bc90d74373c94cdd4d8b230 /utils | |
| parent | 41926c10ea2e8496ce4b528262f5047ccbe6f155 (diff) | |
| download | dove-8f8d41413ff775b6d721059783a0e2de4f90f50c.tar.xz dove-8f8d41413ff775b6d721059783a0e2de4f90f50c.zip | |
feat: add configuration management and server setup
- Implemented configuration file creation and loading in config.go.
- Added default configuration content embedded in embed.go.
- Introduced logging middleware for HTTP requests.
- Created Makefile for build and setup automation.
- Integrated Tailwind CSS and HTMX for frontend styling and interactivity.
- Developed basic authentication flow with login and dashboard pages.
- Enhanced error handling and user feedback in templates.
- Updated dependencies in go.mod and go.sum.
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/auth/auth.go | 8 | ||||
| -rw-r--r-- | utils/logger/logger.go | 2 | ||||
| -rw-r--r-- | utils/meta/title.go | 7 |
3 files changed, 12 insertions, 5 deletions
diff --git a/utils/auth/auth.go b/utils/auth/auth.go index 5abb496..b3d322c 100644 --- a/utils/auth/auth.go +++ b/utils/auth/auth.go @@ -1,6 +1,7 @@ package auth import ( + "dove/config" "dove/session" "github.com/gofiber/fiber/v2" @@ -17,12 +18,11 @@ func IsAuthenticated(context *fiber.Ctx) bool { func RequireAuthentication(handler fiber.Handler) fiber.Handler { return func(context *fiber.Ctx) error { - switch IsAuthenticated(context) { - case true: + if !config.AuthEnabled || IsAuthenticated(context) { return handler(context) - default: - return fiber.ErrUnauthorized } + + return fiber.ErrUnauthorized } } diff --git a/utils/logger/logger.go b/utils/logger/logger.go index b1d1809..a08b68b 100644 --- a/utils/logger/logger.go +++ b/utils/logger/logger.go @@ -15,7 +15,7 @@ var ( atomicLevel zap.AtomicLevel ) -func Init() { +func init() { atomicLevel = zap.NewAtomicLevelAt(zapcore.InfoLevel) encoderConfig := zapcore.EncoderConfig{ diff --git a/utils/meta/title.go b/utils/meta/title.go new file mode 100644 index 0000000..f6514e7 --- /dev/null +++ b/utils/meta/title.go @@ -0,0 +1,7 @@ +package meta + +import "github.com/gofiber/fiber/v2" + +func SetPageTitle(context *fiber.Ctx, title string) { + context.Locals("PageTitle", title) +} |
