spa

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spa creates a set of middlewares for use when serving a Single Page Application from an API server.

The problem with `echo.middleware.Static` is that it doesn't handle non-root routes, so you end up with 404s/403s/whatever, instead of redirecting to serving the index.html file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(static echo.MiddlewareFunc, handle Matcher) echo.MiddlewareFunc

func MiddlewareWithConfig

func MiddlewareWithConfig(cfg Config) echo.MiddlewareFunc

Types

type Config

type Config struct {
	// If Handle returns true, the route is treated as a static route (passed to the Static middleware).
	// Required.
	Handle Matcher
	// The middleware used for handling static routes.
	// See echo.middleware.Static for info on configuration.
	// Required.
	Static echo.MiddlewareFunc
	// When Handle returns true, this is the path passed to the Static middleware.
	// Defaults to index.html.
	Path string
}

type Matcher

type Matcher func(r *http.Request) (bool, error)

Jump to

Keyboard shortcuts

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