http

package
v0.0.0-...-0d6871a Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileServer

func FileServer(r chi.Router, path string, root http.FileSystem, assetDir string)

FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.

func ServerError

func ServerError(w http.ResponseWriter, err error)

ServerError logs the given error before responding to the request with an Internal Server error. TODO consider taking an error code and (optional) message, which can be conveyed to client, ie.:

"Error code: xyz. If the problem persist, please inform system administrator
with references to the error code."

func WithLocalizer

func WithLocalizer() func(next http.Handler) http.Handler

WithLocalizer is a middleware which stores a Localizer in the request context, with language extracted from the Accept-Language HTTP headers if present.

Types

type Server

type Server struct {

	// Addr is the bind address for the tcp listener.
	Addr string
	// Default language
	Lang language.Tag
	// contains filtered or unexported fields
}

Server represents the HTTP server responsible for serving Sirkulators admin interface.

func NewServer

func NewServer(ctx context.Context, assetsDir string, db *sqlitex.Pool, idx *search.Index) *Server

NewServer returns a new Server with the given database and index and assets settings.

func (*Server) Close

func (s *Server) Close() error

Close closes the Server, and peform a graceful shutdown (TODO verify)

func (*Server) Open

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

Open starts to listen at the Server's host:port address, and starts serving incomming connections.

Directories

Path Synopsis
package client TODO rename httpclient?
package client TODO rename httpclient?

Jump to

Keyboard shortcuts

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