serve

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 9 Imported by: 0

README

Serve

Go systme library based http listener with some default daily use middlewares

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware = func(http.Handler) http.Handler

type Option

type Option struct {
	Logger       *slog.Logger
	Host         string
	ReadTimeOut  time.Duration
	WriteTimeOut time.Duration
	Port         uint16
}

func (*Option) Address

func (o *Option) Address() string

type Server

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

func New

func New(opt Option) *Server

New server instance

func (*Server) Handle

func (s *Server) Handle(pattern string, handler http.Handler)

Handle registers the handler for the given pattern.

func (*Server) HandleFunc

func (s *Server) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

func (*Server) ServeHTTP added in v0.0.4

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

func (*Server) Start

func (s *Server) Start()

Start listen & serve

func (*Server) Use

func (s *Server) Use(middleware ...Middleware)

Use middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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