api

package module
v0.0.0-...-5648782 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCarrierHandler

func CreateCarrierHandler(c *gin.Context)

CreateCarrierHandler deserializes the POST request body as a FreightCarrierModel. The endpoint attempts to create a new instance of the carrier. If it fails the function is aborted with the error in the response body and a status code of 400. By default the response body does not contain the carrier created. it must be requested calling a GET endpoint later on. The status code 201 Created is returned on success.

func CreateRouterGroup

func CreateRouterGroup(router gin.IRouter) *gin.RouterGroup

RegisterHandlers appends the carrier routes to the gin router passed as the first argument. Creates a router group with the prefix "/carriers" and registers the following routes:

- GET /carriers

- GET /carriers/:id

- POST /carriers

- PUT /carriers/:id

- DELETE /carriers/:id

Returns the router group created.

func DeleteCarrierHandler

func DeleteCarrierHandler(c *gin.Context)

func GetCarrierHandler

func GetCarrierHandler(c *gin.Context)

GetCarrierHandler is a gin request handler for fetching a single Freight Carrier based on their identifier. The rout expects to have the carrier database interface attached to the gin context.

func GetCarriersHandler

func GetCarriersHandler(c *gin.Context)

GetCarriersHandler is a handler function that retrieves all carriers from the database. The response is a JSON array of carrier objects.

Query Params: `page`, `pageSize`, `include`

func GetPaginatedLink(currentUrl string, page, pageSize int) string

GetPaginatedLink will return the current url passed in query parameters `page=` and `pageSize=` with the parameters passed in.

func UnwrapError

func UnwrapError(errors []error) []string

func UpdateCarrierHandler

func UpdateCarrierHandler(c *gin.Context)

Types

type PaginatedQuery

type PaginatedQuery struct {
	Page     int      `json:"page" form:"page"`         // Page of results to retrieve. Default is 0.
	PageSize int      `json:"pageSize" form:"pageSize"` // Number of results to retrieve per page. Default is 10. The max recommended is 100.
	Include  []string `json:"include" form:"include"`   // List of fields to include in the response. Default is all fields.
}

type PaginatedQueryResponse

type PaginatedQueryResponse struct {
	Page     int    `json:"page" form:"page"`         // The page number to retrieve starting with 0 as the first page. Default is 0.
	PageSize int    `json:"pageSize" form:"pageSize"` // The number of items to retrieve per page. The max recommended page size is 100. Default is 10.
	Pages    int    `json:"pages" form:"pages"`       // The total number of pages available given the query. Default is 0.
	Total    int    `json:"total" form:"total"`       // The total number of items available given the query. Default is 0.
	Next     string `json:"next" form:"next"`         // The URL to retrieve the next page of results. Default is an empty string.
	Previous string `json:"previous" form:"previous"` // The URL to retrieve the previous page of results. Default is an empty string.
	Entities interface{}
}

type ValidatorKeys

type ValidatorKeys string
const (
	// CreateCarrierValidationKey is the key that should be used for when creating a
	// validator specifically for when the POST /carriers route is called to create
	// a new freight carrier
	CreateCarrierValidatorKey ValidatorKeys = "CreateCarrierValidator"
	// UpdateCarrierValidatorKey is the key that should be used for when creating a
	// validator specifically for when the PUT /carriers/:id route is called to update
	// an existing freight carrier
	UpdateCarrierValidatorKey ValidatorKeys = "UpdateCarrierValidator"
)

Jump to

Keyboard shortcuts

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