http

package
v0.0.0-...-60da083 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrCodeFromStatus

func ErrCodeFromStatus(code int) string

ErrCodeFromStatus returns the corresponding error code for an HTTP status code.

func ListenAndServeDebug

func ListenAndServeDebug() error

func NewSessionManager

func NewSessionManager() *scs.SessionManager

func StatusCode

func StatusCode(err error) int

StatusCode returns the HTTP status code for an error code.

Types

type Error

type Error struct {
	Message string `json:"error"`
}

type Server

type Server struct {

	// config values
	Addr               string
	Domain             string
	TLS                bool
	APIKey             string
	CORSAllowedOrigins string
	// AssetsDirectory is the path to the frontend HTML/CSS/JavaScript
	AssetsDirectory string

	Logger todo.Logger
	// LoggerMiddleware is exposed for testing purposes.
	LoggerMiddleware func(http.Handler) http.Handler
	SessionManager   *scs.SessionManager
	ItemListService  todo.ItemListService
	UserService      todo.UserService
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) CreateSession

func (s *Server) CreateSession(ctx context.Context, user *todo.User) error

func (*Server) DestroySession

func (s *Server) DestroySession(ctx context.Context) error

func (*Server) Listen

func (s *Server) Listen() (err error)

func (*Server) Port

func (s *Server) Port() int

Port returns the TCP port for the running server. This is useful in tests where we allocate a random port by using ":0".

func (*Server) RenewSession

func (s *Server) RenewSession(ctx context.Context) error

func (*Server) Scheme

func (s *Server) Scheme() string

func (*Server) Shutdown

func (s *Server) Shutdown() error

func (*Server) URL

func (s *Server) URL() string

URL returns the local base URL of the running server.

Jump to

Keyboard shortcuts

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