utils

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Environment = &Config{}

Functions

func LoadEnvironment

func LoadEnvironment() error

func TryWriteJson added in v0.2.0

func TryWriteJson(w io.Writer, data any) error

Try to marshal data and write it to io.Writer

func TryWriteJsonResponse added in v0.2.0

func TryWriteJsonResponse(w http.ResponseWriter, code int, data any) error

Try to marshal data and write it to http response. Writes a 500 error if it fails to marshal.

func WriteJsonResponse

func WriteJsonResponse(w http.ResponseWriter, code int, data any) bool

Invokes TryWriteJsonResponse. StdOut and returns a false on error

Types

type Config

type Config struct {
	// Env is the environment to run the server in.
	// Either "production" or "development".
	// Optional, ENV: Defaults to "development"
	Env string

	// The secret key used to sign and verify JWT access tokens.
	// Please ensure this is at least 32 characters long, random and not guessable.
	// Required, JWT_ACCESS_SECRET
	JwtAccessSecret string

	// The secret key used to sign and verify JWT refresh tokens.
	// Please ensure this is at least 32 characters long, random and not guessable.
	// Required, JWT_REFRESH_SECRET
	JwtRefreshSecret string

	// The port for the server to listen on.
	// Optional, PORT: Defaults to 3000
	Port int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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