icchttp

package
v0.0.0-...-bd60060 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package icchttp contains helper function to handle http requests.

The handers are defined by its own package (icc, applause...).

Index

Constants

View Source
const (
	// Path is the basic path for all handlers of this service.
	Path = "/system/icc"
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(next http.Handler, auth Authenticater) http.Handler

AuthMiddleware checks the user id of the request.

func Error

func Error(w http.ResponseWriter, err error)

Error sends an error message to the client as json-message.

If the error does not have a Type() string message, it is handled as 500er. In other case, it is handled as 400er.

func ErrorNoStatus

func ErrorNoStatus(w io.Writer, err error)

ErrorNoStatus is like Error(), but does not write a status message.

func HandleHealth

func HandleHealth(mux *http.ServeMux)

HandleHealth returns 200 (if the service is running).

func HealthClient

func HealthClient(ctx context.Context, useHTTPS bool, host, port string, insecure bool) error

HealthClient sends a http request to a server to fetch the health status.

Types

type Authenticater

type Authenticater interface {
	Authenticate(http.ResponseWriter, *http.Request) (context.Context, error)
	FromContext(context.Context) int
}

Authenticater knowns how to authenticate a request.

Jump to

Keyboard shortcuts

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