http

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: LGPL-3.0

README

Http

The Http module contains a set uf useful http packages that can be used in any Http backend project.

Import

Import the module

go get github.com/go-bumbu/http

Server

The server package contains boilerplate to create an http server. Features:

  • you can specify a main handler and an optional observability handler
    • the observability handler is intended to expose details like metrics, runtime controls or hprof endpoint
  • the server can safely shut down with os kill signals
  • it exposes a Stop() method to safely shut down both servers.

Middleware

Middleware contains several middleware handlers to facilitate writing backends

  • delay: useful during development for AJAX calls, adds delay to a response
  • jsonErr: wraps all http errors into a json response, also allows to generalize errors
    • setting the flag genericMessage to true, will not return the error string but the generic error string matching the response code instead
  • prometheus: adds an http_duration_seconds bucket to measure volume and duration of requests per response code
  • zerolog: middleware that will write a log message to a zerolog logger capturing every request

Handlers

  • spa: simple Single page application handler to serve SPAs embedded into go code

Directories

Path Synopsis
handlers
spa
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳