common

package
v0.0.0-...-8f89ab8 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CorsOrigins

func CorsOrigins() string

CorsOrigins returns the proper CORS origin configuration for the current environment

func HandleTemplate

func HandleTemplate(
	c *fiber.Ctx,
	template string,
	name string,
	data interface{},
	status int,
) error

HandleTemplate will execute the http template engine with the given template, name, data, and status

func IsProd

func IsProd() bool

IsProd returns true if running in production

func PickFS

func PickFS(useDisk bool, e embed.FS, dir string) http.FileSystem

PickFS returns either an embedded FS or an on-disk FS for the given directory path

func SendAlert

func SendAlert(page, content string) error

SendAlert will POST a webhook to discord for alerting purposes

Types

type Env

type Env string
const (
	Prod Env = "prod"
	Dev  Env = "dev"
)

func GetEnv

func GetEnv() Env

GetEnv returns the current environment

type MapHash

type MapHash struct {
	Lat     float64
	Lon     float64
	Zoom    float64
	Pitch   float64
	Bearing float64
}

MapHash is a struct containing map page route parameters

type PageModel

type PageModel struct {
	Env      Env
	PageName string
	Data     interface{}
}

PageModel contains runtime information that can be used during page template rendering

func GenPageModel

func GenPageModel(name string, data interface{}) PageModel

GenPageModel generates the global page model

type StrictFs

type StrictFs struct {
	Fs http.FileSystem
}

StrictFs is a Custom strict filesystem implementation to prevent directory listings for resources

func (StrictFs) Open

func (sfs StrictFs) Open(path string) (http.File, error)

Open only allows existing files to be pulled, not directories

Jump to

Keyboard shortcuts

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