Categorygithub.com/saucelabs/webserver
modulepackage
0.0.11
Repository: https://github.com/saucelabs/webserver.git
Documentation: pkg.go.dev

# README

webserver

webserver provides a web server:

  • Gracefully handles shutdown
  • Applies best practices such as setting up timeouts
  • Routing powered by Gorilla Mux
  • Logging powered Sypl
  • HTTP server powered by Go built-in HTTP server
  • Observability is first-class:
    • Telemetry powered by Open Telemetry
    • Metrics powered by ExpVar
    • Built-in useful handlers such as liveness, and readiness

Install

$ go get github.com/saucelabs/webserver

Specific version

Example: $ go get github.com/saucelabs/[email protected]

Usage

See example_test.go, and webserver_test.go file.

Documentation

Run $ make doc or check out online.

Development

Check out CONTRIBUTION.

Release

  1. Update CHANGELOG accordingly.
  2. Once changes from MR are merged.
  3. Tag and release.

Roadmap

Check out CHANGELOG.

# Packages

package handler provides a collection of useful/built-in handlers.
package metric provides a collection of useful/built-in metrics.
Package telemetry provides server's telemetry powered by Open Telemetry.

# Functions

New returns a basic web server without: - logging - telemetry - metrics - pre-loaded handlers (Liveness, OK, and Stop).
NewDefault returns a web server with observability: - Metrics: `cmdline`, `memstats`, and `server` - Telemetry: `stdout` provider - Logging: `error`, no file - Pre-loaded handlers (Liveness, OK, and Stop) - Versioned router: `/api/v1`.
WithHandlers sets the list of pre-loaded handlers.
WithLogging sets logging configuration.
WithMetrics sets the list of pre-loaded metrics.
WithReadiness sets server readiness.
WithRouter sets the base router.
WithTelemetry sets telemetry.
WithTimeout sets the maximum duration for each individual timeouts.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

ErrRequesTimeout indicates a request failed to finish, it timed out.

# Structs

Logging settings.
Server definition.
Timeout definition.

# Interfaces

IServer defines what a server does.

# Type aliases

Option allows to define options for the Server.