sparge
Sparge is a Go based SPA (single page web application)
server.
The purpose of sparge is to allow single page frameworks like Aurelia,
Angular, and React to use "pretty urls" (urls without the #) by serving the index.html
file from the assets directory whenever a static file is not found. Sparge will,
however, return 404 if an extension is used in the path, such as favicon.png
, and
that file is not found.
- Look for the path in the assets directory and return that static asset if it exists.
- If the path contains no extension (e.g.,
.html
, .png
, .jpg
), then return index.html
from the assets directory.
- Otherwise, return a 404.
Dependencies
Sparge is built with the following dependencies:
Build
The following are instructions to build the sparge binary. This project uses
glide to manage dependencies.
$ cd $GOPATH
$ go get github.com/BrewdHQ/sparge
$ cd sparge
$ cd src/BrewdHQ/sparge
$ glide install
$ go build
Usage
Put sparge
in your path and run sparge help
for commands and flags.
Commands:
$ sparge help
NAME:
sparge - A SPA (single-page application) server
USAGE:
sparge [global options] command [command options] [arguments...]
VERSION:
1.0.0
COMMANDS:
start Start the SPA server
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
Start:
$ sparge help start
NAME:
sparge start - Start the SPA server
USAGE:
sparge start [command options] [arguments...]
OPTIONS:
--dir value, -d value (default: "./public")
--port value, -p value (default: "8080")
Sparge will serve assets from the ./public
directory by default. Be sure
to specifiy an alternate directory as needed.
Version History
1.5.0
- Use the lastest from echo server master branch
- Fixes bug with https redirect loop when server is behind a proxy
1.4.0
1.3.0
- Added redirect-https flag
- Removed CORS (doesn't make sense for the SPA server, should be handled on the API server)
1.2.0
- Allow settings to be configured with environment variables
0.2.0
- Switched from gin-gonic to echo
- Added a startup banner
0.1.0
The first version
- Start server with a custom port
- Start server with a custom assets directory