server

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 46 Imported by: 0

Documentation

Overview

Package server implements the application's server API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedirectCookie

func NewRedirectCookie(uri string) *http.Cookie

NewRedirectCookie creates a URL redirection cookie for an anonymous user.

func NewRememberMeCookie

func NewRememberMeCookie(selector, validator string) *http.Cookie

NewRememberMeCookie creates a cookie for when the user checks remember on login.

func NewSessionCookie

func NewSessionCookie(value string) *http.Cookie

NewSessionCookie creates a session cookie for a logged-in user.

Types

type Key

type Key string

Key is a type alias for a context key.

const (
	SearchOptsKey Key = "opts"   // SearchOptsKey is the key to identify a SearchOptionsRecipes struct.
	UserIDKey     Key = "userID" // UserIDKey is the key to identify a user ID.
)

type Server

type Server struct {
	Brokers      *models.Broker
	Email        services.EmailService
	Files        services.FilesService
	Integrations services.IntegrationsService
	Logger       *slog.Logger
	Repository   services.RepositoryService
	Router       *http.ServeMux
	Scraper      scraper.IScraper
}

Server is the web application's configuration object.

func NewServer

func NewServer(repo services.RepositoryService) *Server

NewServer creates a Server.

func (*Server) Run

func (s *Server) Run()

Run starts the web server.

type SessionDataMap added in v1.1.0

type SessionDataMap struct {
	Data map[uuid.UUID]int64
	// contains filtered or unexported fields
}

SessionDataMap is a type alias to map UUIDs to int64s.

var SessionData SessionDataMap

SessionData maps a UUID to a user id. It's used to track who is logged in session-wise.

func (*SessionDataMap) Get added in v1.2.0

func (s *SessionDataMap) Get(sid uuid.UUID) (int64, bool)

Get safely gets a value from the SessionDataMap.

func (*SessionDataMap) Load added in v1.1.0

func (s *SessionDataMap) Load(r io.Reader)

Load populates the SessionDataMap from the reader.

func (*SessionDataMap) Save added in v1.1.0

func (s *SessionDataMap) Save(w io.Writer)

Save saves the SessionDataMap to the writer in the CSV format.

func (*SessionDataMap) Set added in v1.2.0

func (s *SessionDataMap) Set(sid uuid.UUID, userID int64)

Set safely adds an entry to SessionDataMap.

Jump to

Keyboard shortcuts

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