server

package
v0.0.0-...-54f8ee0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateLimiter

func RateLimiter(lmt *limiter.Limiter) func(next http.Handler) http.Handler

func TokenFromHeader

func TokenFromHeader(r *http.Request) string

TokenFromHeader tries to retreive the token string from the "Authorization" reqeust header: "Authorization: BEARER T".

Types

type App

type App struct {
	Name    string
	Version string
	URL     string
}

App ...

type Page

type Page struct {
	Name        string
	Title       string
	URLPath     string
	Description string
	Time        time.Time
}

Page ...

type Server

type Server struct {
	Logger *log.Logger
	Config *config.Config
	Router *chi.Mux
	Client *http.Client
	Games  []*game.Game
	sync.RWMutex
}

Server holds all the data the App needs

func New

func New(l *log.Logger, c *config.Config) *Server

New returns a pointer to the main server struct

func (*Server) CreateGame

func (s *Server) CreateGame(size int, distribution float64, timelimit uint, protected bool) *game.Game

func (*Server) GetGameByID

func (s *Server) GetGameByID(id int) *game.Game

func (*Server) Setup

func (s *Server) Setup()

Setup starts the HTTP Server

func (*Server) VerifyToken

func (s *Server) VerifyToken() func(next http.Handler) http.Handler

VerifyToken implements a simple middleware handler.

type Token

type Token string

Jump to

Keyboard shortcuts

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