server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package server implements the HTTP server for flipper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(s *Server) error

Option is a functional option for the server.

func WithAddr

func WithAddr(addr string) Option

WithAddr sets the address the server listens on.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger for the server.

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout sets the shutdown timeout for the server.

func WithStaticFS

func WithStaticFS(staticFS fs.FS) Option

WithStaticFS sets the static file system for the server.

func WithTemplateEngine

func WithTemplateEngine(t *template.Engine) Option

WithTemplateEngine sets the template engine for the server.

type Server

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

Server is a simple HTTP server.

func New

func New(opts ...Option) (*Server, error)

New creates a new server with the given options.

func (*Server) ListenAndServe

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

ListenAndServe listens on the configured address and serves requests. When the context is cancelled, it attempts to gracefully shut down.

func (*Server) ServeHTTP

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

ServeHTTP implements the http.Handler interface.

Jump to

Keyboard shortcuts

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