Documentation
¶
Overview ¶
Package handler provides HTTP handlers for the application.
Index ¶
- type AccountHandler
- func (h *AccountHandler) Create(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) GetByID(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) List(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) Update(w http.ResponseWriter, r *http.Request)
- type AdminHandler
- func (h *AdminHandler) ForceDeleteUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) GetTenant(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) GetUser(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) HardDeleteTenant(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ListAuditLogs(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ListTenants(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) ListUsers(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) RestoreTenant(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) SuspendTenant(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UpdateTenantPlan(w http.ResponseWriter, r *http.Request)
- type AuthHandler
- type CategoryHandler
- func (h *CategoryHandler) Create(w http.ResponseWriter, r *http.Request)
- func (h *CategoryHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *CategoryHandler) GetByID(w http.ResponseWriter, r *http.Request)
- func (h *CategoryHandler) List(w http.ResponseWriter, r *http.Request)
- func (h *CategoryHandler) Update(w http.ResponseWriter, r *http.Request)
- type CreateAccountRequest
- type CreateCategoryRequest
- type CreateTransactionRequest
- type InviteUserRequest
- type RequestOTPRequest
- type TenantHandler
- type TokenResponse
- type TransactionHandler
- func (h *TransactionHandler) Create(w http.ResponseWriter, r *http.Request)
- func (h *TransactionHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *TransactionHandler) GetByID(w http.ResponseWriter, r *http.Request)
- func (h *TransactionHandler) List(w http.ResponseWriter, r *http.Request)
- func (h *TransactionHandler) Update(w http.ResponseWriter, r *http.Request)
- type UpdateAccountRequest
- type UpdateCategoryRequest
- type UpdateTenantPlanRequest
- type UpdateTenantRequest
- type UpdateTransactionRequest
- type VerifyOTPRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountHandler ¶ added in v1.2.0
type AccountHandler struct {
// contains filtered or unexported fields
}
AccountHandler handles account-related HTTP requests.
func NewAccountHandler ¶ added in v1.2.0
func NewAccountHandler(service domain.AccountService) *AccountHandler
NewAccountHandler creates a new AccountHandler.
func (*AccountHandler) Create ¶ added in v1.2.0
func (h *AccountHandler) Create(w http.ResponseWriter, r *http.Request)
Create handles POST /v1/accounts
func (*AccountHandler) Delete ¶ added in v1.2.0
func (h *AccountHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete handles DELETE /v1/accounts/{id}
func (*AccountHandler) GetByID ¶ added in v1.2.0
func (h *AccountHandler) GetByID(w http.ResponseWriter, r *http.Request)
GetByID handles GET /v1/accounts/{id}
func (*AccountHandler) List ¶ added in v1.2.0
func (h *AccountHandler) List(w http.ResponseWriter, r *http.Request)
List handles GET /v1/accounts
func (*AccountHandler) Update ¶ added in v1.2.0
func (h *AccountHandler) Update(w http.ResponseWriter, r *http.Request)
Update handles PATCH /v1/accounts/{id}
type AdminHandler ¶ added in v1.5.0
type AdminHandler struct {
// contains filtered or unexported fields
}
func NewAdminHandler ¶ added in v1.5.0
func NewAdminHandler(service domain.AdminService) *AdminHandler
func (*AdminHandler) ForceDeleteUser ¶ added in v1.5.0
func (h *AdminHandler) ForceDeleteUser(w http.ResponseWriter, r *http.Request)
ForceDeleteUser DELETE /v1/admin/users/{id}
func (*AdminHandler) GetTenant ¶ added in v1.5.0
func (h *AdminHandler) GetTenant(w http.ResponseWriter, r *http.Request)
GetTenant GET /v1/admin/tenants/{id}
func (*AdminHandler) GetUser ¶ added in v1.5.0
func (h *AdminHandler) GetUser(w http.ResponseWriter, r *http.Request)
GetUser GET /v1/admin/users/{id}
func (*AdminHandler) HardDeleteTenant ¶ added in v1.5.0
func (h *AdminHandler) HardDeleteTenant(w http.ResponseWriter, r *http.Request)
HardDeleteTenant DELETE /v1/admin/tenants/{id}
func (*AdminHandler) ListAuditLogs ¶ added in v1.5.0
func (h *AdminHandler) ListAuditLogs(w http.ResponseWriter, r *http.Request)
ListAuditLogs GET /v1/admin/audit-logs
func (*AdminHandler) ListTenants ¶ added in v1.5.0
func (h *AdminHandler) ListTenants(w http.ResponseWriter, r *http.Request)
ListTenants GET /v1/admin/tenants
func (*AdminHandler) ListUsers ¶ added in v1.5.0
func (h *AdminHandler) ListUsers(w http.ResponseWriter, r *http.Request)
ListUsers GET /v1/admin/users
func (*AdminHandler) RestoreTenant ¶ added in v1.5.0
func (h *AdminHandler) RestoreTenant(w http.ResponseWriter, r *http.Request)
RestoreTenant POST /v1/admin/tenants/{id}/restore
func (*AdminHandler) SuspendTenant ¶ added in v1.5.0
func (h *AdminHandler) SuspendTenant(w http.ResponseWriter, r *http.Request)
SuspendTenant POST /v1/admin/tenants/{id}/suspend
func (*AdminHandler) UpdateTenantPlan ¶ added in v1.5.0
func (h *AdminHandler) UpdateTenantPlan(w http.ResponseWriter, r *http.Request)
UpdateTenantPlan PATCH /v1/admin/tenants/{id}/plan
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
AuthHandler handles authentication-related HTTP requests.
func NewAuthHandler ¶
func NewAuthHandler(service domain.AuthService) *AuthHandler
NewAuthHandler creates a new AuthHandler with the given service and logger.
func (*AuthHandler) RefreshToken ¶
func (h *AuthHandler) RefreshToken(w http.ResponseWriter, r *http.Request)
RefreshToken handles POST /v1/auth/token/refresh
func (*AuthHandler) RequestOTP ¶
func (h *AuthHandler) RequestOTP(w http.ResponseWriter, r *http.Request)
RequestOTP handles POST /v1/auth/otp/request
func (*AuthHandler) VerifyOTP ¶
func (h *AuthHandler) VerifyOTP(w http.ResponseWriter, r *http.Request)
VerifyOTP handles POST /v1/auth/otp/verify
type CategoryHandler ¶ added in v1.3.0
type CategoryHandler struct {
// contains filtered or unexported fields
}
func NewCategoryHandler ¶ added in v1.3.0
func NewCategoryHandler(service domain.CategoryService) *CategoryHandler
func (*CategoryHandler) Create ¶ added in v1.3.0
func (h *CategoryHandler) Create(w http.ResponseWriter, r *http.Request)
Create handles POST /v1/categories
func (*CategoryHandler) Delete ¶ added in v1.3.0
func (h *CategoryHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete handles DELETE /v1/categories/{id}
func (*CategoryHandler) GetByID ¶ added in v1.3.0
func (h *CategoryHandler) GetByID(w http.ResponseWriter, r *http.Request)
GetByID handles GET /v1/categories/{id}
func (*CategoryHandler) List ¶ added in v1.3.0
func (h *CategoryHandler) List(w http.ResponseWriter, r *http.Request)
List handles GET /v1/categories
func (*CategoryHandler) Update ¶ added in v1.3.0
func (h *CategoryHandler) Update(w http.ResponseWriter, r *http.Request)
Update handles PATCH /v1/categories/{id}
type CreateAccountRequest ¶ added in v1.2.0
type CreateAccountRequest struct {
Name string `json:"name" validate:"required,min=1,max=100"`
Type domain.AccountType `json:"type" validate:"required,oneof=checking savings credit_card investment"`
Currency string `json:"currency" validate:"required,len=3"`
InitialCents int64 `json:"initial_cents" validate:"required"`
}
CreateAccountRequest defines the payload for creating a new account.
type CreateCategoryRequest ¶ added in v1.3.0
type CreateCategoryRequest struct {
ParentID *string `json:"parent_id" validate:"omitempty"`
Icon *string `json:"icon" validate:"omitempty"`
Color *string `json:"color" validate:"omitempty"`
Name string `json:"name" validate:"required,min=1,max=100"`
Type domain.CategoryType `json:"type" validate:"required"`
}
type CreateTransactionRequest ¶ added in v1.4.0
type CreateTransactionRequest struct {
OccurredAt time.Time `json:"occurred_at" validate:"required"`
AccountID string `json:"account_id" validate:"required"`
CategoryID string `json:"category_id" validate:"required"`
Description string `json:"description" validate:"required,min=1,max=255"`
Type domain.TransactionType `json:"type" validate:"required,oneof=income expense transfer"`
AmountCents int64 `json:"amount_cents" validate:"required,gt=0"`
}
CreateTransactionRequest defines the incoming payload for creating a transaction.
type InviteUserRequest ¶ added in v1.1.0
type InviteUserRequest struct {
Email string `json:"email" validate:"required,email"`
Role domain.Role `json:"role" validate:"required,oneof=owner member"`
}
InviteUserRequest defines the payload for inviting a user.
type RequestOTPRequest ¶
type RequestOTPRequest struct {
Email string `json:"email" validate:"required,email"`
}
RequestOTPRequest defines the payload for requesting an OTP.
type TenantHandler ¶ added in v1.1.0
type TenantHandler struct {
// contains filtered or unexported fields
}
TenantHandler handles tenant-related HTTP requests.
func NewTenantHandler ¶ added in v1.1.0
func NewTenantHandler(service domain.TenantService) *TenantHandler
NewTenantHandler creates a new TenantHandler.
func (*TenantHandler) GetMe ¶ added in v1.1.0
func (h *TenantHandler) GetMe(w http.ResponseWriter, r *http.Request)
GetMe handles GET /v1/tenants/me
func (*TenantHandler) InviteUser ¶ added in v1.1.0
func (h *TenantHandler) InviteUser(w http.ResponseWriter, r *http.Request)
InviteUser handles POST /v1/tenants/me/invite
func (*TenantHandler) UpdateMe ¶ added in v1.1.0
func (h *TenantHandler) UpdateMe(w http.ResponseWriter, r *http.Request)
UpdateMe handles PATCH /v1/tenants/me
type TokenResponse ¶
type TokenResponse struct {
// ExpiresAt is the timestamp when the access token expires.
ExpiresAt time.Time `json:"expires_at"`
// AccessToken is the PASETO access token.
//
//nolint:gosec
AccessToken string `json:"access_token"`
// RefreshToken is the PASETO refresh token.
//
//nolint:gosec
RefreshToken string `json:"refresh_token"`
}
TokenResponse defines the successful authentication response.
type TransactionHandler ¶ added in v1.4.0
type TransactionHandler struct {
// contains filtered or unexported fields
}
TransactionHandler handles HTTP requests for transaction management.
func NewTransactionHandler ¶ added in v1.4.0
func NewTransactionHandler(service domain.TransactionService) *TransactionHandler
NewTransactionHandler creates a new TransactionHandler instance.
func (*TransactionHandler) Create ¶ added in v1.4.0
func (h *TransactionHandler) Create(w http.ResponseWriter, r *http.Request)
Create handles POST /v1/transactions
func (*TransactionHandler) Delete ¶ added in v1.4.0
func (h *TransactionHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete handles DELETE /v1/transactions/{id}
func (*TransactionHandler) GetByID ¶ added in v1.4.0
func (h *TransactionHandler) GetByID(w http.ResponseWriter, r *http.Request)
GetByID handles GET /v1/transactions/{id}
func (*TransactionHandler) List ¶ added in v1.4.0
func (h *TransactionHandler) List(w http.ResponseWriter, r *http.Request)
List handles GET /v1/transactions
func (*TransactionHandler) Update ¶ added in v1.4.0
func (h *TransactionHandler) Update(w http.ResponseWriter, r *http.Request)
Update handles PATCH /v1/transactions/{id}
type UpdateAccountRequest ¶ added in v1.2.0
type UpdateAccountRequest struct {
Name *string `json:"name" validate:"omitempty,min=1,max=100"`
Currency *string `json:"currency" validate:"omitempty,len=3"`
}
UpdateAccountRequest defines the payload for updating an account.
type UpdateCategoryRequest ¶ added in v1.3.0
type UpdateTenantPlanRequest ¶ added in v1.5.0
type UpdateTenantPlanRequest struct {
Plan domain.TenantPlan `json:"plan" validate:"required,oneof=free pro business"`
}
type UpdateTenantRequest ¶ added in v1.1.0
type UpdateTenantRequest struct {
Name *string `json:"name" validate:"omitempty,min=2,max=100"`
}
UpdateTenantRequest defines the payload for updating a tenant.
type UpdateTransactionRequest ¶ added in v1.4.0
type UpdateTransactionRequest struct {
OccurredAt *time.Time `json:"occurred_at" validate:"omitempty"`
CategoryID *string `json:"category_id" validate:"omitempty"`
Description *string `json:"description" validate:"omitempty,min=1,max=255"`
AmountCents *int64 `json:"amount_cents" validate:"omitempty,gt=0"`
}
UpdateTransactionRequest defines the incoming payload for updating a transaction.
type VerifyOTPRequest ¶
type VerifyOTPRequest struct {
Email string `json:"email" validate:"required,email"`
Code string `json:"code" validate:"required,len=6"`
}
VerifyOTPRequest defines the payload for verifying an OTP.