routes

package
v0.0.0-...-f79cf23 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func API

func API(router *mux.Router)

func App

func App(router *mux.Router, dir fs.File, pathPrefix, indexPath string)

func GraphQLProxy

func GraphQLProxy(router *mux.Router, endpoint string) error

Types

type SPA

type SPA struct {
	// contains filtered or unexported fields
}

func NewSPA

func NewSPA(dir fs.File, indexPath string) SPA

NewSPA serves the provided directory as a Single-Page Application. Read more on how the app is actually served in `routes.SPA.ServeHTTP`.

func (SPA) ServeHTTP

func (spa SPA) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP inspects the URL path to locate a file within the static dir on the SPA handler. If a file is found, it will be served. If not, the file located at the index path on the SPA handler will be served. This is suitable behavior for serving an SPA (single page application). HTML, plaintext and JSON files will NEVER cache to guarantee an always up-to-date app. Will cache JS and CSS files forever since we assume their file names are/contain content hashes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL