handler

package
v0.0.0-...-2ae9e5c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType = "Content-Type"
	MimeJSONUTF8      = "application/json; charset=utf-8"
	MimeHTMLUTF8      = "text/html; charset=utf-8"
)

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON[T any]() goexpress.Middleware

func FromParamsContext

func FromParamsContext[T any](ctx context.Context) (any, T, bool)

func NewParamsContext

func NewParamsContext[T any](ctx context.Context, t T) context.Context

func ValidateInput

func ValidateInput[T any](validate *validator.Validate) goexpress.Middleware

Types

type APIHandler

type APIHandler struct {
	Base BaseAPIHandler
	User UserAPIHandler
}

func NewAPIHandler

func NewAPIHandler(svc service.Service) *APIHandler

type APIResponse

type APIResponse[T any] struct {
	Message string            `json:"message,omitempty"`
	Errors  map[string]string `json:"errors,omitempty"`
	Data    T                 `json:"data,omitempty"`
}

type App

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

func NewApp

func NewApp(deps *AppDependencies) *App

func (*App) Router

func (a *App) Router() *goexpress.Router

func (*App) SetupMiddlewares

func (a *App) SetupMiddlewares()

func (*App) SetupRoutes

func (a *App) SetupRoutes()

type AppDependencies

type AppDependencies struct {
	Config    *config.Config
	DB        *sql.DB
	Router    *goexpress.Router
	Validator *validator.Validate
	Template  *Template
	Hasher    security.Hasher
}

type BaseAPIHandler

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

func NewBaseAPIHandler

func NewBaseAPIHandler(svc service.BaseService) *BaseAPIHandler

func (*BaseAPIHandler) HandleHealth

func (h *BaseAPIHandler) HandleHealth(w http.ResponseWriter, r *http.Request)

type BaseHandler

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

func NewBaseHandler

func NewBaseHandler(t *Template) *BaseHandler

func (*BaseHandler) HandleDashboard

func (h *BaseHandler) HandleDashboard(w http.ResponseWriter, r *http.Request)

type Handler

type Handler struct {
	Base BaseHandler
	User UserHandler
}

func NewHandler

func NewHandler(tmpl *Template) *Handler

type RegisterUserRequest

type RegisterUserRequest struct {
	Email           string `json:"email,omitempty" validate:"required,email"`
	Password        string `json:"password,omitempty" validate:"required"`
	PasswordConfirm string `json:"password_confirm,omitempty" validate:"required,eqfield=Password"`
}

type RegisterUserResponse

type RegisterUserResponse struct {
	ID        string    `json:"id"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Template

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

func NewTemplate

func NewTemplate(cfg config.TemplateConfig) (*Template, error)

func (*Template) Render

func (t *Template) Render(w http.ResponseWriter, r *http.Request, name string, data any)

type UserAPIHandler

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

func NewUserAPIHandler

func NewUserAPIHandler(userService service.UserService) *UserAPIHandler

func (*UserAPIHandler) HandleUserRegister

func (h *UserAPIHandler) HandleUserRegister(w http.ResponseWriter, r *http.Request)

type UserHandler

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

func NewUserHandler

func NewUserHandler(t *Template) *UserHandler

func (*UserHandler) HandleRegister

func (h *UserHandler) HandleRegister(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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