response

package
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: BSD-3-Clause Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-http/v4/response

Go package providing simple http.Handler implementations for common responses.

Handlers

Handler Description
NullHandler() Does nothing, resulting in an empty HTTP 200 response.
NotImplementedHandler() Responds with an HTTP 501 (Not Implemented) error.
DisabledHandler(disabled, next) Middleware that responds with an HTTP 503 (Service Unavailable) error if disabled is true, otherwise it serves next.
PingHandler(response) Responds with an HTTP 204 (No Content). If response is not empty it is sent in the X-ping header.
PingPongHandler() Like PingHandler with a response value of PONG. Useful for health checks.

Example

package main

import (
	"net/http"

	"github.com/aaronland/go-http/v5/response"
)

func main() {

	ping_handler, _ := response.PingPongHandler()

	mux := http.NewServeMux()
	mux.Handle("/ping", ping_handler)
	mux.Handle("/beta", response.DisabledHandler(true, response.NullHandler()))

	http.ListenAndServe("localhost:8080", mux)
}

Documentation

Overview

Package response provides simple HTTP handlers for common responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisabledHandler

func DisabledHandler(disabled bool, next http.Handler) http.Handler

DisabledHandler is a middleware handler that returns an HTTP 503 (Service unavailable) error if 'disabled' is true. Otherwise it serves 'next'.

func NotImplementedHandler

func NotImplementedHandler() http.Handler

NotImplementedHandler returns an `http.Handler` that responds with an HTTP 501 (Not Implemented) error.

func NullHandler

func NullHandler() http.Handler

NullHandler returns an `http.Handler` that does nothing, resulting in an empty HTTP 200 response.

func PingHandler

func PingHandler(response string) (http.Handler, error)

PingHandler returns an `http.Handler` that responds with an HTTP 204 (No Content) status. If 'response' is not empty it is sent in the `X-ping` response header.

func PingPongHandler

func PingPongHandler() (http.Handler, error)

PingPongHandler returns an `http.Handler` equivalent to `PingHandler` with a response value of "PONG".

Types

This section is empty.

Jump to

Keyboard shortcuts

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