server

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 25 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

func NewTemplateCache

func NewTemplateCache() (map[string]*template.Template, error)

NewTemplateCache creates a template cache as a map

Types

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 {
	Messager       Messager
	PinSize        int
	MaxPinAttempts int
	MaxExpire      time.Duration
	WebRoot        string
	Version        string
	Domain         string
	TemplateCache  map[string]*template.Template
}

Server is a rest with store

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