Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jrschumacher/go-spaserve
https://github.com/jrschumacher/go-spaserve
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jrschumacher/go-spaserve
- Owner: jrschumacher
- License: mit
- Created: 2024-07-17T14:31:21.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-04T20:40:35.000Z (about 1 month ago)
- Last Synced: 2024-10-09T22:23:08.952Z (about 1 month ago)
- Language: Go
- Size: 122 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go SPA Serve
[![codecov](https://codecov.io/gh/jrschumacher/go-spaserve/graph/badge.svg?token=W99WAK10IX)](https://codecov.io/gh/jrschumacher/go-spaserve)Go SPA Serve is a simple package that serves static files specifically focused on serving single page applications (SPA).
Generally, this can be used to instead of the stdlib `http.FileServer`, but the main use case is to serve a SPA with a
single entry point (e.g. `index.html`) and let the client-side router handle the rest.In addition to serving static files, this package also provides a way to load environment variables from a Go struct at
runtime by injecting them into the head tag of the served HTML file.## Problem
Vite is a fantastic build tool, but it doesn't support loading environment variables at runtime.
This becomes quite a problem when you build a single image for multiple environments or need to
build images for on-premises deployments where you can't bake in the environment variables.