Documentation
¶
Index ¶
- Variables
- func AcceptDonation(repo interface{ ... }) http.HandlerFunc
- func AuthMiddleware(next http.Handler) http.Handler
- func ConfirmPasswordReset(repo interface{ ... }) http.HandlerFunc
- func CreateAllocation(repo interface{ ... }) http.HandlerFunc
- func CreateItem(repo interface{ ... }) http.HandlerFunc
- func CreateOrUpdateDonation(repo interface{ ... }, action string) http.HandlerFunc
- func CreateOrUpdateStock(repo interface{ ... }) http.HandlerFunc
- func CreateRequest(repo interface{ ... }) http.HandlerFunc
- func CreateRequestItemAllocation(repo interface{ ... }) http.HandlerFunc
- func CreateUnit(repo interface{ ... }) http.HandlerFunc
- func DeleteDonation(repo interface{ ... }) http.HandlerFunc
- func DeleteItem(repo interface{ ... }) http.HandlerFunc
- func DeleteRequest(repo interface{ ... }) http.HandlerFunc
- func DeleteRequestItemAllocation(repo interface{ ... }) http.HandlerFunc
- func DeleteUnit(repo interface{ ... }) http.HandlerFunc
- func EditRequestItemAllocation(repo interface{ ... }) http.HandlerFunc
- func ErrInvalidRequest(err error) render.Renderer
- func ErrRender(err error) render.Renderer
- func ErrUnauthorized(err error) render.Renderer
- func GetAllAllocations(repo interface{ ... }) http.HandlerFunc
- func GetAllDonations(repo interface{ ... }) http.HandlerFunc
- func GetAllItem(repo interface{ ... }) http.HandlerFunc
- func GetAllRequest(repo interface{ ... }) http.HandlerFunc
- func GetAllStock(repo interface{ ... }) http.HandlerFunc
- func GetAllUnit(repo interface{ ... }) http.HandlerFunc
- func GetDonation(donationRepo interface{ ... }) http.HandlerFunc
- func GetRequest(repo interface{ ... }) http.HandlerFunc
- func GetUserDonations(repo interface{ ... }) http.HandlerFunc
- func GetUserRequests(repo interface{ ... }) http.HandlerFunc
- func Login(repo interface{ ... }) http.HandlerFunc
- func PaginationCtx(next http.Handler) http.Handler
- func RefreshToken(w http.ResponseWriter, r *http.Request)
- func Register(repo interface{ ... }) http.HandlerFunc
- func ResetPassword(repo interface{ ... }) http.HandlerFunc
- func SendEmail(subject string, body string, receiver string) error
- func SendPasswordResetConfirmationMail(userEmail string, requestID string) error
- func UpdateDonation(repo interface{ ... }) http.HandlerFunc
- func UpdateRequest(repo interface{ ... }) http.HandlerFunc
- func UserCtx(repo interface{ ... }) func(http.Handler) http.Handler
- type API
- type AllocationDataPage
- type AllocationResource
- type AuthResource
- type ConfirmResetPasswordRequest
- type CreateAllocationRequest
- type CreateDonationRequest
- type CreateItemRequest
- type CreateRequestRequest
- type CreateUnitRequest
- type DonationDataPage
- type DonationResource
- type ErrResponse
- type ItemResource
- type LoginRequest
- type LoginResponse
- type Page
- type Paging
- type RegisterRequest
- type RequestDataPage
- type RequestResource
- type ResetPasswordRequest
- type StockDataPage
- type StockRequest
- type StockResource
- type UnitResource
- type UpdateDonationRequest
- type UpdateRequestRequest
Constants ¶
This section is empty.
Variables ¶
var ( UserIDCtxKey = &contextKey{"User_id"} UserCtxKey = &contextKey{"User"} PageCtxKey = &contextKey{"Pagination"} )
Common ctx key.
var ( ErrInvalidUserID = errors.New("INVALID_USER_ID") ErrMissingReqFields = errors.New("MISSING_REQUEST_FIELDS") ErrInvalidRole = errors.New("INVALID_ROLE") )
common error message
Functions ¶
func AcceptDonation ¶
func AcceptDonation(
repo interface {
model.HasAcceptDonation
model.HasCreateOrUpdateStock
},
) http.HandlerFunc
AcceptDonation accepts donation by given id.
func AuthMiddleware ¶
AuthMiddleware to handle request jwt token
func ConfirmPasswordReset ¶
func ConfirmPasswordReset(repo interface {
model.HasConfirmPasswordResetRequest
}) http.HandlerFunc
ConfirmPasswordReset confirms password reset request.
func CreateAllocation ¶
func CreateAllocation(
repo interface {
model.HasCreateAllocation
model.HasIsStockAvailable
model.HasCreateOrUpdateStock
model.HasGetRequest
},
) http.HandlerFunc
CreateAllocation creates new allocation.
func CreateItem ¶
func CreateItem(repo interface{ model.HasCreateItem }) http.HandlerFunc
CreateItem creates new item.
func CreateOrUpdateDonation ¶
func CreateOrUpdateDonation(repo interface {
model.HasCreateOrUpdateDonation
}, action string) http.HandlerFunc
CreateOrUpdateDonation return donations
func CreateOrUpdateStock ¶
func CreateOrUpdateStock(repo interface{ model.HasCreateOrUpdateStock }) http.HandlerFunc
CreateOrUpdateStock creates or updates stock.
func CreateRequest ¶
func CreateRequest(repo interface{ model.HasCreateRequest }) http.HandlerFunc
CreateRequest handles request creation
func CreateRequestItemAllocation ¶
func CreateRequestItemAllocation(repo interface {
model.HasCreateRequestItemAllocation
}) http.HandlerFunc
CreateRequestItemAllocation create RequestItemAllocation
func CreateUnit ¶
func CreateUnit(repo interface{ model.HasCreateUnit }) http.HandlerFunc
CreateUnit creates new unit.
func DeleteDonation ¶
func DeleteDonation(repo interface{ model.HasDeleteDonation }) http.HandlerFunc
DeleteDonation deletes donation by given donation id.
func DeleteItem ¶
func DeleteItem(repo interface{ model.HasDeleteItem }) http.HandlerFunc
DeleteItem deletes item by given item id.
func DeleteRequest ¶
func DeleteRequest(repo interface{ model.HasDeleteRequest }) http.HandlerFunc
DeleteRequest deletes request by given request id.
func DeleteRequestItemAllocation ¶
func DeleteRequestItemAllocation(repo interface {
model.HasDeleteRequestItemAllocation
}) http.HandlerFunc
DeleteRequestItemAllocation delete RequestItemAllocation
func DeleteUnit ¶
func DeleteUnit(repo interface{ model.HasDeleteUnit }) http.HandlerFunc
DeleteUnit deletes unit by given id.
func EditRequestItemAllocation ¶
func EditRequestItemAllocation(repo interface {
model.HasEditRequestItemAllocation
}) http.HandlerFunc
EditRequestItemAllocation edit RequestItemAllocation
func ErrInvalidRequest ¶
ErrInvalidRequest to render invalid request error
func ErrUnauthorized ¶
ErrUnauthorized to render unathorized error
func GetAllAllocations ¶
func GetAllAllocations(
repo interface {
model.HasGetAllAllocations
model.HasGetTotalAllocationCount
model.HasGetRequest
},
) http.HandlerFunc
GetAllAllocations gets all allocations.
func GetAllDonations ¶
func GetAllDonations(
repo interface {
model.HasGetAllDonations
model.HasGetTotalDonationCount
},
) http.HandlerFunc
GetAllDonations gets all requests.
func GetAllItem ¶
func GetAllItem(repo interface{ model.HasGetAllItem }) http.HandlerFunc
GetAllItem gets all item.
func GetAllRequest ¶
func GetAllRequest(
repo interface {
model.HasGetAllRequest
model.HasGetTotalRequestCount
},
) http.HandlerFunc
GetAllRequest gets all requests.
func GetAllStock ¶
func GetAllStock(repo interface {
model.HasGetAllStock
}) http.HandlerFunc
GetAllStock return stocks
func GetAllUnit ¶
func GetAllUnit(repo interface{ model.HasGetAllUnit }) http.HandlerFunc
GetAllUnit gets all unit.
func GetDonation ¶
func GetDonation(donationRepo interface{ model.HasGetDonation }) http.HandlerFunc
GetDonation handles get donation detail given id.
func GetRequest ¶
func GetRequest(repo interface{ model.HasGetRequest }) http.HandlerFunc
GetRequest handles get request detail
func GetUserDonations ¶
func GetUserDonations(
repo interface {
model.HasGetUserDonations
model.HasGetTotalUserDonationCount
},
) http.HandlerFunc
GetUserDonations gets all user donations.
func GetUserRequests ¶
func GetUserRequests(
repo interface {
model.HasGetUserRequests
model.HasGetTotalUserRequestCount
},
) http.HandlerFunc
GetUserRequests gets all user requests.
func PaginationCtx ¶
PaginationCtx middleware is used to exctract page and size query param
func RefreshToken ¶
func RefreshToken(w http.ResponseWriter, r *http.Request)
RefreshToken refreshes jwt token.
func Register ¶
func Register(repo interface {
model.HasCreateNewUser
model.HasGetUserByEmail
}) http.HandlerFunc
Register new user handler
func ResetPassword ¶
func ResetPassword(repo interface {
model.HasCreatePasswordResetRequest
}) http.HandlerFunc
ResetPassword creates new password reset request.
func SendPasswordResetConfirmationMail ¶
SendPasswordResetConfirmationMail sends password reset confirmation mail.
func UpdateDonation ¶
func UpdateDonation(repo interface{ model.HasUpdateDonation }) http.HandlerFunc
UpdateDonation handles donation update
func UpdateRequest ¶
func UpdateRequest(repo interface{ model.HasUpdateRequest }) http.HandlerFunc
UpdateRequest handles request update
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API provides application resources and handlers.
type AllocationDataPage ¶
type AllocationDataPage struct {
Data []*model.AllocationData `boil:"data" json:"data"`
Pages *Page `boil:"pages" json:"pages"`
}
AllocationDataPage struct
type AllocationResource ¶
type AllocationResource struct {
*model.AllocationDatastore
*model.StockDataStore
*model.UserDatastore
*model.RequestDatastore
}
AllocationResource struct
type AuthResource ¶
type AuthResource struct {
*model.UserDatastore
*model.PasswordResetRequestDatastore
}
AuthResource holds user data store information.
type ConfirmResetPasswordRequest ¶
type ConfirmResetPasswordRequest struct {
NewPassword string `json:"newPassword"`
}
ConfirmResetPasswordRequest struct
type CreateAllocationRequest ¶
type CreateAllocationRequest struct {
RequestID string `json:"requestID"`
Date time.Time `json:"date"`
PhotoURL string `json:"photoURL"`
AllocationItems models.AllocationItemSlice `json:"items"`
}
CreateAllocationRequest struct
type CreateDonationRequest ¶
type CreateDonationRequest struct {
DonationItems []*models.DonationItem `json:"donationItems"`
}
CreateDonationRequest struct
type CreateItemRequest ¶
CreateItemRequest struct
type CreateRequestRequest ¶
type CreateRequestRequest struct {
RequestItems models.RequestItemSlice `json:"requestItems"`
}
CreateRequestRequest struct
type CreateUnitRequest ¶
CreateUnitRequest struct
type DonationDataPage ¶
type DonationDataPage struct {
Data []*model.DonationData `boil:"data" json:"data"`
Pages *Page `boil:"pages" json:"pages"`
}
DonationDataPage struct
type DonationResource ¶
type DonationResource struct {
*model.DonationDataStore
*model.UserDatastore
*model.StockDataStore
}
DonationResource struct
type ErrResponse ¶
type ErrResponse struct {
Err error `json:"-"`
HTTPStatusCode int `json:"-"`
StatusText string `json:"status"`
AppCode int64 `json:"code,omitempty"`
ErrorText string `json:"error,omitempty"`
}
ErrResponse contains err, http_status_code, status_text, app_code, error_text
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
Render error response
type ItemResource ¶
type ItemResource struct {
*model.ItemDatastore
*model.UserDatastore
}
ItemResource holds item data store information.
type LoginRequest ¶
LoginRequest struct
type LoginResponse ¶
LoginResponse struct
type Page ¶
type Page struct {
Current int `boil:"current" json:"current"`
Total int `boil:"total" json:"total"`
First bool `boil:"first" json:"first"`
Last bool `boil:"last" json:"last"`
}
Page struct
type RegisterRequest ¶
RegisterRequest struct
type RequestDataPage ¶
type RequestDataPage struct {
Data []*model.RequestData `boil:"data" json:"data"`
Pages *Page `boil:"pages" json:"pages"`
}
RequestDataPage struct
type RequestResource ¶
type RequestResource struct {
*model.RequestDatastore
*model.UserDatastore
*model.RequestItemAllocationDatastore
}
RequestResource holds request data store.
type ResetPasswordRequest ¶
type ResetPasswordRequest struct {
Email string `json:"email"`
}
ResetPasswordRequest struct
type StockDataPage ¶
type StockDataPage struct {
Data []*model.StockData `boil:"data" json:"data"`
Pages *Page `boil:"pages" json:"pages"`
}
StockDataPage struct
type StockRequest ¶
StockRequest struct
type StockResource ¶
type StockResource struct {
*model.StockDataStore
*model.UserDatastore
}
StockResource holds stock data store information.
type UnitResource ¶
type UnitResource struct {
*model.UnitDatastore
*model.UserDatastore
}
UnitResource holds unit data store information.
type UpdateDonationRequest ¶
type UpdateDonationRequest struct {
DonationItems models.DonationItemSlice `json:"donationItems"`
}
UpdateDonationRequest struct
type UpdateRequestRequest ¶
type UpdateRequestRequest struct {
RequestItems models.RequestItemSlice `json:"requestItems"`
}
UpdateRequestRequest struct