modulepackage
0.0.0-20210921054058-b88d7a60cbd7
Repository: https://github.com/grindlemire/web.git
Documentation: pkg.go.dev
# README
web
A minimal library for creating webservers in go
It is built on gorilla mux and handles lifecycle management, jwt auth (if you want), http redirect, middleware, and endpoint specification if you want it to. The goal is to eliminate the need to rewrite a lot of plumbing while allowing you to customize the server for more complex usecases.
Why?
Because I often want to create a minimal webserver using gorilla mux and I found myself following this pattern quite a bit. I find that frameworks are often restrictive so this is not a framework. This is a library that is intended to help with basic plumbing for an http server. You can overwrite whatever you want (for example the router or middleware) with more complex logic if/when you want to.
# Functions
AddAllMiddleware adds a set of middleware to the server.
AddAuthedEndpoint adds some authed endpoints to the server.
AddAuthedMiddleware adds a set of middleware to the server.
AddEndpoint adds some public endpoints to the server.
AddPublicMiddleware adds a set of middleware to the server.
CORSOptions configures cors options for the server.
DisableDefaultMiddleware will disable the server from adding request fingerprinting prometheus metrics for all routes, and jwt auth for authed routes.
Handler configures the rest handler that will route and respond to requests.
HTTPPort configures the port the http redirect is served over.
HTTPSPort configures the port the https server serves on.
JWTSigningCertPath configures the path to the public key that will be used to validate jwts.
JWTSigningKey configures the path to the private key that will be used to validate the jwts.
JWTSigningKeyPath configures the path to the private key that will be used to validate the jwts.
JWTSingingKeyPassphrase configures the passphrase that is required to use the signing key (if there is one).
NewServer creates a new http server with a router.
SetLanding will set the top level home path for the server.
SetLogger sets a logger if you want one.
SetTimeout sets the http timeout for requests and responses.
TLSCertPath configures the path to the tls certificate.
TLSKeyPath configures the path to the tls private key.
# Interfaces
Logger is a logger you can use to optionally print out information.
# Type aliases
Opt is an option for configuring the rest server.