http

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package http implements helpers for HTTP requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RealIP

func RealIP(r *http.Request) string

RealIP resolves the real client IP address from the request.

Types

type Server

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

Server is a convenience wrapper around the standard library HTTP server.

func NewServer

func NewServer(ctx context.Context, addr string, h http.Handler, opts ...SrvOptFunc) *Server

NewServer returns a server with the base context ctx.

func (*Server) Close

func (s *Server) Close() error

Close closes the server.

func (*Server) Serve

func (s *Server) Serve(errFn func(error))

Serve starts the server in a non-blocking way.

func (*Server) Shutdown

func (s *Server) Shutdown(timeout time.Duration) error

Shutdown attempts to close all server connections.

type SrvOptFunc

type SrvOptFunc func(*http.Server)

SrvOptFunc represents a server option function.

func WithH2C added in v2.2.0

func WithH2C() SrvOptFunc

WithH2C allows the server to handle h2c connections.

func WithReadTimeout added in v2.2.2

func WithReadTimeout(d time.Duration) SrvOptFunc

WithReadTimeout sets the server read timeout.

func WithTLSConfig

func WithTLSConfig(cfg *tls.Config) SrvOptFunc

WithTLSConfig sets the serve tls config.

func WithWriteTimeout added in v2.2.2

func WithWriteTimeout(d time.Duration) SrvOptFunc

WithWriteTimeout sets the server write timeout.

Directories

Path Synopsis
Package healthz provides HTTP healthz handling.
Package healthz provides HTTP healthz handling.
Package middleware provides reusable HTTP middleware.
Package middleware provides reusable HTTP middleware.
Package render provides HTTP output rendering helper functions.
Package render provides HTTP output rendering helper functions.
Package request provides functions add and extract information from an http request.
Package request provides functions add and extract information from an http request.
Package server provides a generic HTTP server.
Package server provides a generic HTTP server.

Jump to

Keyboard shortcuts

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