api

package
v0.0.0-...-d2ff1c5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateAccountParams

type CreateAccountParams struct {
	Currency string `json:"currency" binding:"required,currency"`
}

type CreateUserParams

type CreateUserParams struct {
	Username string `json:"username" binding:"required,min=6,alphanum"` // alphanum: only allow alphanumeric characters
	Password string `json:"password" binding:"required,min=6"`
	FullName string `json:"full_name" binding:"required,min=1,max=100"`
	Email    string `json:"email" binding:"required,email"`
}

type GetAccountParams

type GetAccountParams struct {
	ID int64 `uri:"id" binding:"required,min=1"` // uri: path parameter
}

type ListAccountParams

type ListAccountParams struct {
	PageID   int32 `form:"page_id" binding:"required,min=1"` // form: query parameter
	PageSize int32 `form:"page_size" binding:"required,min=5,max=10"`
}

type LoginParams

type LoginParams struct {
	Username string `json:"username" binding:"required,min=6,alphanum"` // alphanum: only allow alphanumeric characters
	Password string `json:"password" binding:"required,min=6"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken string       `json:"access_token"`
	User        UserResponse `json:"user"`
}

type Server

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

Server serves HTTP requests for our banking service.

func NewServer

func NewServer(config util.Config, store db.Store) (*Server, error)

NewServer creates a new HTTP server and setup routing.

func (*Server) Start

func (server *Server) Start(address string) error

Start runs the HTTP server on a specific address.

type TransferInputParams

type TransferInputParams struct {
	FromAccountID int64  `json:"from_account_id" binding:"required,min=1"`
	ToAccountID   int64  `json:"to_account_id" binding:"required,min=1"`
	Amount        int64  `json:"amount" binding:"required,gt=0"`
	Currency      string `json:"currency" binding:"required,currency"`
}

TransferTxParams contains the input parameters of the transfer transaction

type UpdateAccountBalanceJSON

type UpdateAccountBalanceJSON struct {
	Amount int64 `json:"amount" binding:"required,ne=0"`
}

type UpdateAccountBalanceUri

type UpdateAccountBalanceUri struct {
	ID int64 `uri:"id" binding:"required,min=1"` // uri: path parameter
}

type UserResponse

type UserResponse struct {
	Username          string    `json:"username"`
	FullName          string    `json:"full_name"`
	Email             string    `json:"email"`
	PasswordChangedAt time.Time `json:"password_changed_at"`
	CreatedAt         time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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