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 AuthHandler
- type CreateAccountRequest
- type InviteUserRequest
- type RequestOTPRequest
- type TenantHandler
- type TokenResponse
- type UpdateAccountRequest
- type UpdateTenantRequest
- 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 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 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 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 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 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 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.