server

package
v0.0.1-alpha2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(token string, key string) (string, error)

Decrypt decodes key and decrypts token with it.

func Encrypt

func Encrypt(secret string) (token, key string, err error)

Encrypt takes the plaintext secret, generates a key and produces a token.

func RedisClient

func RedisClient() *redis.Client

RedisClient returns the redis client based on the environment.

func RedisCloseConnections

func RedisCloseConnections() error

RedisCloseConnections closes connections to the server.

func RedisIsAlive

func RedisIsAlive() error

RedisIsAlive returns an error if we cannot communicate with redis.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...ServerOption) *Server

New returns a server with the provided opts, if any.

func (*Server) Run

func (srv *Server) Run() error

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Shutdown executes shutdown logic for the server instance.

type ServerOption

type ServerOption = func(*Server)

func LogTo

func LogTo(w io.Writer) ServerOption

LogTo sets where to log server logs.

func SetListenAddress

func SetListenAddress(address string) ServerOption

SetListenAddress sets the server's listen address to address

func WithHostOverride

func WithHostOverride(override string) ServerOption

WithHostOverride informs the server that links should override the default host value with override.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix informs the server that links should include prefix in the URI. This does not change path handling, and only impacts link rendering when providing the user with their credential link.

func WithProto

func WithProto(proto string) ServerOption

WithProto sets the proto returned for password links. Should be http or https

func WithRedisKeyPrefix

func WithRedisKeyPrefix(prefix string) ServerOption

WithRedisKeyPrefix instructs the server to prefix all keys inserted into the database with prefix.

Jump to

Keyboard shortcuts

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