server

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package server provides rest-like api and serves static assets as well

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(l log.L, flags ...LoggerFlag) func(http.Handler) http.Handler

Logger middleware prints http log. Customized by set of LoggerFlag

Types

type Config added in v1.3.0

type Config struct {
	Domain   string
	WebRoot  string
	Protocol string
	Branding string
	// validation parameters
	PinSize        int
	MaxPinAttempts int
	MaxExpire      time.Duration
}

Config is a configuration for the server

type JSON

type JSON map[string]interface{}

JSON is a map alias, just for convenience

type LoggerFlag

type LoggerFlag int

LoggerFlag type

const (
	LogAll LoggerFlag = iota
	LogBody
)

logger flags enum

type Messager

type Messager interface {
	MakeMessage(duration time.Duration, msg, pin string) (result *store.Message, err error)
	LoadMessage(key, pin string) (msg *store.Message, err error)
}

Messager interface making and loading messages

type Server

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

Server is a rest with store

func New added in v1.3.0

func New(m Messager, version string, cfg Config) (Server, error)

New creates a new server with template cache

func (Server) Run

func (s Server) Run(ctx context.Context) error

Run the lister and request's router, activate rest server

Directories

Path Synopsis
Package validator provides functionality for validating and sanitizing data.
Package validator provides functionality for validating and sanitizing data.

Jump to

Keyboard shortcuts

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