utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeMetadataLinks(itemCount int, limit int, offset int, path string) []interface{}

ComputeMetadataLinks Create the metadata links associated to the response

func EndWithLowerCase added in v0.1.0

func EndWithLowerCase(s string) bool

func FormatDataTime

func FormatDataTime(
	stringTime string,
	closingDate string,
	offsetInSec int,
	location time.Location,
) (time.Time, error)

FormatDataTime Take the date, the hours and the timezone offset and return the related time.Time object

func GetIntParams

func GetIntParams(c *gin.Context, paramName string) (int, error)

GetIntParams Get the int param paramName passed into the request. Return an error if not specified or empty, the value either

func GetOpenAPIData

func GetOpenAPIData(openDataAPIResponse *domains.BordeauxAPIResponse) error

GetOpenAPIData Get forecasts data from the Open-data API Populate the *domains.OpenDataAPIResponse pointer if the data are correct

func GetSpecialEventName added in v0.1.0

func GetSpecialEventName(reason domains.ClosingReason, eventName string) string

GetSpecialEventName Return the special name event (if this is a special event)

func GetStringParams

func GetStringParams(c *gin.Context, paramName string) string

GetStringParams Get the string param paramName passed into the request. Return empty string if not specified or empty, the value either

func GetTimezoneFromHeader

func GetTimezoneFromHeader(c *gin.Context) (*time.Location, error)

GetTimezoneFromHeader Get the timezone passed into the request header. Return an error if the header is missing and/or mal formatted. The value either

func InitOpenApi added in v0.1.0

func InitOpenApi(logger *log.Entry)

InitOpenApi Init the logger

func JsonLoggerMiddleware

func JsonLoggerMiddleware() gin.HandlerFunc

func MapBoats

func MapBoats(
	closingReason domains.ClosingReason,
	boatNames string,
	closingDuration time.Duration,
	circulationClosingDate time.Time,
	alreadySeenBoatNames *[]string,
) []domains.Boat

MapBoats Return a []domains.Boat of a boat crossing forecast. closingReason : If it is a maintenance forecast, no computation boatNames : The raw string containing the boat name(s) closingDuration : Used to compute the approximated crossing time circulationClosingDate : Used to compute the approximated crossing time alreadySeenBoatNames : Array pointer to keep track of the boats. Used to compute the boat Maneuver forecastID : Used to compute the "self" link

func MapClosingReason

func MapClosingReason(stringClosingReason string) domains.ClosingReason

MapClosingReason Return the corresponding domains.ClosingReason according to the string value

func MapClosingType

func MapClosingType(stringClosingType string) domains.ClosingType

MapClosingType Return the corresponding domains.ClosingType according to the string value

func StartWithUpperCase added in v0.1.0

func StartWithUpperCase(s string) bool

Types

This section is empty.