# README
wsfn
wsfn is a package for common web functions Caltech Library uses in various Golang based Caltech Library tools and services. The goal is to standardize our handling of web interactions.
- wsfn.CORSPolicy is a structure for adding CORS headers to a http Handler
- StaticRouter is a http Handler Function for working with static routes
- RedirectRouter handles simple target prefix, destination prefix redirect handling
- AddRedirectRoute adds a target prefix and destination prefix
- HasRedirectRoutes return true if any redirect routes are configured
- RedirectRouter uses the internal redirect data to handle redirects
- ReverseProxy router lets front other web services.
An example webserver is also provided to demonstrate some of the functionality available with this package. The webserver is intended for instructional purposes only and shouldn't be used in a production setting.
# Packages
No description provided by the author
# Functions
AccessHandler is a wrapping handler that checks if Access.Routes matches the req.URL.Path and if so applies access contraints.
DefaultInit generates a default TOML initialization file.
DefaultService is http, port 8000 on localhost.
DefaultWebService setups to listen for http://localhost:8000 with the htdocs of the current working directory.
FmtHelp lets you process a text block with simple curly brace markup.
IsDotPath checks to see if a path is requested with a dot file (e.g.
LoadAccess loads a TOML or JSON access file.
LoadRedirects reads a CSV file of redirects and returns a map[string]string of from/to static rediects.
LoadWebService loads a configuration file of *WebService.
MakeRedirectService takes a m[string]string of redirects and loads it into our service's private routes attribute.
MakeSafeFileSystem without a *WebService takes a doc root and returns a SafeFileSystem struct.
RequestLogger logs the request based on the request object passed into it.
ResponseLogger logs the response based on a request, status and error message.
StaticRouter scans the request object to either add a .html extension or prevent serving a dot file path.
# Constants
No description provided by the author
ReleaseDate, the date version.go was generated.
ReleaseHash, the Git hash when version.go was generated.
Version number of release.
# Structs
Access holds the necessary configuration for doing basic auth authentication.
CORSPolicy defines the policy elements for our CORS settings.
RedirectService holds our redirect targets in an ordered list and a map to our applied routes.
SafeFile are ones that do NOT have a "." as a prefix on the path.
SafeFileSystem is used to hide dot file paths from our web services.
No description provided by the author
Service holds the description needed to startup a service e.g.
WebService describes all the configuration and capabilities of running a wsfn based web service.