server

package
v0.0.0-...-57dad53 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr                 string
	Debug                bool
	Host                 string
	FacebookClientID     string
	FacebookClientSecret string
	GoogleClientID       string
	GoogleClientSecret   string
	MediaDir             string
	SecretKey            string
	SiteTheme            string
	SiteTitle            string
	SiteDescription      string
	Conn                 *db.Conn
	Matcher              *matcher.Matcher
}

Config stores the configuration for the embedded web server.

type Recorder

type Recorder struct {
	http.ResponseWriter
	StartTime  time.Time
	StatusCode int
}

Recorder is an implementation of ResponseWriter that remembers the status code that was set so that it can be accessed.

func NewRecorder

func NewRecorder(w http.ResponseWriter) *Recorder

NewRecorder creates and initializes a new recorder.

func (*Recorder) Elapsed

func (r *Recorder) Elapsed() time.Duration

Elapsed determines how long the method took to execute.

func (*Recorder) WriteHeader

func (r *Recorder) WriteHeader(statusCode int)

WriteHeader invokes the ResponseWriter implementation and stores the status code.

type Server

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

Server provides the web interface.

func New

func New(cfg *Config) (*Server, error)

New creates and initializes the server.

func (*Server) Close

func (s *Server) Close()

Close shuts down the server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP loads the current user from the database if logged in.

Jump to

Keyboard shortcuts

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