Documentation ¶
Overview ¶
Package http provides http-specific configuration types and functionality.
Index ¶
Constants ¶
View Source
const ( HeaderAllowOrigin = "Access-Control-Allow-Origin" HeaderAuthorization = "Authorization" HeaderContentType = "Content-Type" )
Variables ¶
This section is empty.
Functions ¶
func NewStaticHandler ¶
func SPAFileServer ¶
func SPAFileServer(root http.FileSystem, handlerSPA SPAHandler) http.Handler
SPAFileServer wraps the http.FileServer checking to see if the url path exists first.
If the file fails to exist it calls the supplied handlerSPA function ¶
The implementation can choose to either modify the request, e.g. change the URL path and return true to have the default FileServer handling to still take place, or return false to stop further processing, for example if you wanted to write a custom response
This code borrows heavily from https://gist.github.com/lummie/91cd1c18b2e32fa9f316862221a6fd5c
Types ¶
type CorsConfig ¶
type SPAHandler ¶
type SPAHandler = func(w http.ResponseWriter, r *http.Request) (doDefaultFileServe bool)
SPAHandler provides the function signature for passing to the SPAFileServer
type StaticHostingConfig ¶
Click to show internal directories.
Click to hide internal directories.