utils

package
v0.0.0-...-30a0ae6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Consts = map[string]reflect.Value{}
View Source
var Functions = map[string]reflect.Value{
	"ComputeStationTriviaURLs":     reflect.ValueOf(ComputeStationTriviaURLs),
	"DurationAbs":                  reflect.ValueOf(DurationAbs),
	"FormatPortugueseDurationLong": reflect.ValueOf(FormatPortugueseDurationLong),
	"FormatPortugueseMonth":        reflect.ValueOf(FormatPortugueseMonth),
	"FormatPortugueseMonthShort":   reflect.ValueOf(FormatPortugueseMonthShort),
	"Fudge":                        reflect.ValueOf(Fudge),
	"GetClientIP":                  reflect.ValueOf(GetClientIP),
	"Int64Abs":                     reflect.ValueOf(Int64Abs),
	"RequestIsTLS":                 reflect.ValueOf(RequestIsTLS),
	"SchedulesToLines":             reflect.ValueOf(SchedulesToLines),
	"StationConnectionURLs":        reflect.ValueOf(StationConnectionURLs),
}
View Source
var SupportedLocales = [...]string{"pt", "en", "es", "fr", "de"}

SupportedLocales contains the supported locales for extra and meta content

View Source
var Types = map[string]reflect.Type{}
View Source
var Variables = map[string]reflect.Value{
	"SupportedLocales": reflect.ValueOf(&SupportedLocales),
}

Functions

func ComputeStationTriviaURLs

func ComputeStationTriviaURLs(station *types.Station) map[string]string

ComputeStationTriviaURLs returns a mapping from locales to URLs of the HTML file containing the trivia for the given station

func DisturbanceReasonString

func DisturbanceReasonString(disturbance *types.Disturbance, alwaysReturn bool) string

DisturbanceReasonString returns a short human-friendly string explaining why a disturbance happened/what it is related to

func DurationAbs

func DurationAbs(n time.Duration) time.Duration

DurationAbs is math.Abs for time.Duration

func FormatPortugueseDurationLong

func FormatPortugueseDurationLong(d time.Duration) string

FormatPortugueseDurationLong returns a long string representation of a duration in Portuguese

func FormatPortugueseMonth

func FormatPortugueseMonth(month time.Month) string

FormatPortugueseMonth returns the Portuguese name for a month

func FormatPortugueseMonthShort

func FormatPortugueseMonthShort(month time.Month) string

FormatPortugueseMonthShort returns the Portuguese name abbreviation for a month

func Fudge

func Fudge(value, approximateTo int) int

Fudge introduces uncertainty in a value

func GetClientIP

func GetClientIP(r *http.Request) (ip string)

GetClientIP retrieves the client IP address from the request information. It detects common proxy headers to return the actual client's IP and not the proxy's.

func Int64Abs

func Int64Abs(n int64) int64

Int64Abs is math.Abs for int64

func RequestIsTLS

func RequestIsTLS(r *http.Request) bool

RequestIsTLS returns whether a request was made over a HTTPS channel Looks at the appropriate headers if the server is behind a proxy

func SchedulesToLines

func SchedulesToLines(schedules []*types.LobbySchedule) []string

SchedulesToLines converts a lobby schedule to a set of human-readable lines

func StationConnectionURLs

func StationConnectionURLs(station *types.Station) map[string]map[string]string

StationConnectionURLs returns a mapping from locales to connection types to URLs of the HTML files containing the connection info for the given station

Types

This section is empty.

Jump to

Keyboard shortcuts

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