app

package
v0.0.0-...-b140ed9 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package app provides the public entry point for the go-core authentication module. Consumers call New to initialize, RegisterRoutes to mount handlers onto a Gin engine, and Close to shut down gracefully.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is the public entry point for the go-core authentication module. All internal services are hidden behind an opaque struct — consumers interact only through RegisterRoutes and Close.

func New

func New(cfg core.Config) (*App, error)

New validates the configuration and initializes the go-core module. It creates and owns its own database connection pool.

func NewWithDB

func NewWithDB(cfg core.Config, pool *pgxpool.Pool) (*App, error)

NewWithDB validates the configuration and initializes the go-core module using an externally managed database connection pool. The caller retains ownership of the pool and is responsible for closing it.

func (*App) AuthMiddleware

func (a *App) AuthMiddleware() gin.HandlerFunc

AuthMiddleware returns a Gin handler that enforces JWT authentication. Drop it into any route or group the consumer controls:

r.GET("/profile", coreApp.AuthMiddleware(), profileHandler)
api := r.Group("/api", coreApp.AuthMiddleware())

func (*App) Close

func (a *App) Close()

Close gracefully shuts down all background services and the database connection pool owned by the module.

func (*App) RegisterRoutes

func (a *App) RegisterRoutes(r *gin.Engine)

RegisterRoutes mounts all go-core HTTP routes (auth, admin, OIDC, etc.) onto the provided Gin engine. The consumer owns the engine and server lifecycle.

Jump to

Keyboard shortcuts

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