common

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

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 9 Imported by: 0

README

Common VOTO services

For our backend infrastructure we often use reusable code. This code is collected in this repository.

Documentation

Index

Constants

View Source
const DEFAULT_ITEMS = 20

Defines the default amount of returned items within an array

View Source
const MAX_ITEMS = 100

Defines maximal amount of returned items within an array

View Source
const MIN_ITEMS = 10

Defines the default amount of returned items within an array

Variables

View Source
var PW_LETTERS = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!§$%&/()=?`*'_:;<>,.-")

Functions

func GetAge

func GetAge(birthdate time.Time) int

func ProcessPaginationInput

func ProcessPaginationInput(l string, p string) (int, int, error)

ProcessPaginationInput parses the user input for limit and page query parameters

func RandSeq

func RandSeq(n int) string

Types

type ErrorResponse

type ErrorResponse struct {
	Status  int32
	Message string
}

type HandlerParams

type HandlerParams struct {
	DbAccessor db.PostgresConnector
	Ctx        context.Context
	Request    events.APIGatewayProxyRequest
}
type Links struct {
	Self string `json:"self"`
	Prev string `json:"prev_page_url"`
	Next string `json:"next_page_url"`
}

func GenerateMetadata

func GenerateMetadata(path string, total int, l int, p int) Links

GenerateMetadata generate a links struct which can be used within MetaData struct to return from API

type Pagination

type Pagination struct {
	Total       int   `json:"total"`
	PerPage     int   `json:"per_page"`
	CurrentPage int   `json:"current_page"`
	LastPage    int   `json:"last_page"`
	From        int   `json:"from"`
	To          int   `json:"to"`
	Links       Links `json:"_links"`
}

func GeneratePagination

func GeneratePagination(total int, per_page int, page int, items int) Pagination

GeneratePagination generates the pagination struct calculated by the input

type VOTODate

type VOTODate time.Time

func (VOTODate) Format

func (j VOTODate) Format(s string) string

func (VOTODate) MarshalJSON

func (j VOTODate) MarshalJSON() ([]byte, error)

func (VOTODate) Time

func (j VOTODate) Time() *time.Time

func (*VOTODate) UnmarshalJSON

func (j *VOTODate) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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