httpok

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

README

Candango HttpOK

Welcome to the world of httpok, your Go library for extending the capabilities of the standard net/http package!

Installation

To get httpok, you can use go get:

go get github.com/candango/httpok

Support

HttpOK is one of Candango Open Source Group initiatives. Available under the Apache License, Version 2.0.

This site and all documentation are licensed under Creative Commons 3.0.

Copyright © 2024 Flavio Garcia

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(next http.Handler, ms ...Middleware) http.Handler

Chain creates a chain of HTTP middleware functions to wrap around a http.Handler. It applies each middleware in the order they are provided, allowing for layered processing of HTTP requests and responses.

Types

type GracefulServer added in v0.0.3

type GracefulServer struct {
	Name string
	*http.Server
	context.Context
	RunLogger
}

GracefulServer combines an HTTP server with a context for graceful shutdown handling.

func (*GracefulServer) Run added in v0.0.3

func (s *GracefulServer) Run(sig ...os.Signal)

Run starts the HTTP server in a goroutine and listens for termination signals to gracefully shut down. It takes optional signals to listen for; if none are provided, it uses default signals.

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware represents a function that can wrap a http.Handler with additional functionality. It takes a http.Handler and returns a new http.Handler that includes the middleware's behavior.

type RunLogger added in v0.0.3

type RunLogger interface {
	Printf(format string, v ...interface{})
	Fatalf(format string, v ...interface{})
}

RunLogger defines the interface for logging used within the GracefulServer's Run method. It provides methods for formatted printing and fatal errors which halt the program.

type WrappedWriter added in v0.0.2

type WrappedWriter struct {
	http.ResponseWriter
	StatusCode int
}

func (*WrappedWriter) WriteHeader added in v0.0.2

func (w *WrappedWriter) WriteHeader(c int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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