Skip to content

Releases: zopdev/static-server

v0.0.9

22 Apr 06:57
cdc4024

Choose a tag to compare

What's Changed

Features

SPA fallback mode (SPA_MODE)

When SPA_MODE=true, extensionless routes that don't match a file now serve index.html with status 200, enabling client-side routing (React Router, Vue Router, etc.) without duplicating index.html as 404.html. Defaults to false — existing setups are unaffected.

Configurable default extension (DEFAULT_EXTENSION)

Replaces the hardcoded .html auto-resolution. Set DEFAULT_EXTENSION=.json (or any extension) to serve extensionless requests from a different file type. Defaults to .html to preserve existing behavior.

Note: only one extension is tried per request. Setting DEFAULT_EXTENSION to a non-html value disables .html auto-resolution. See README for interaction with SPA_MODE.

Multi-platform Docker images (amd64 + arm64)

Images now build for both linux/amd64 and linux/arm64 via Docker buildx with native Go cross-compilation. Apple Silicon users no longer need emulation.

Bug fixes

404 response headers no longer flushed prematurely

The previous handler called w.WriteHeader(404) before http.ServeFile, which flushed headers early and prevented ServeFile from setting Content-Type, Content-Length, and caching headers. A new statusOverrideWriter lets ServeFile set all headers normally and only overrides the status code.

Broader Stat error handling

ServeHTTP now treats any Stat error (permissions, I/O, symlink loop) as "not serveable" and routes to the 404 / SPA fallback, instead of falling through to http.ServeFile with a broken path.

Dockerfile builds all Go files

Build step changed from go build main.go to go build . so handler.go and future files are included.

Refactor & internals

  • Middleware extracted into testable staticFileHandler struct backed by GoFr's file.FileSystem interface.
  • Per-request regexp.MatchString replaced with filepath.Ext — eliminates regex compilation on every request.
  • SPA_MODE parsing uses strconv.ParseBool.
  • Tests replaced non-deterministic go main() + time.Sleep with httptest.NewServer for proper lifecycle.

Dependencies & tooling

  • GoFr upgraded to v1.56.0; replaced deprecated file.New with file.NewLocalFileSystem.
  • GitHub Actions: checkout v4→v6, setup-go v4→v6 (caching default), golangci-lint-action v8→v9.

Compatibility

Fully backward compatible. SPA_MODE defaults to false and DEFAULT_EXTENSION defaults to .html, so services upgrading from v0.0.8 with no env changes behave identically.

Full Changelog: v0.0.8...v0.0.9

v0.0.8

10 Mar 05:56
e8d0988

Choose a tag to compare

What's Changed

Features

1. Config File Hydration

When the CONFIG_FILE_PATH environment variable is set, the server replaces any ${VAR} placeholders in that file at startup using values from the environment (including .env files). The file is rewritten in-place before serving begins.

This is useful for injecting runtime configuration into static front-end apps without rebuilding them.

If any placeholders have no matching environment variable, the server still writes the file (substituting empty strings for missing values) and logs an error listing the unresolved variables.

Full Changelog: v0.0.7...v0.0.8

v0.0.7

09 Mar 06:37
4cb4390

Choose a tag to compare

Release Notes

🚀 New Features

  • Added ARM64 support enabling the image to run on ARM-based systems (e.g., Apple Silicon, AWS Graviton).

🔧 Improvements

  • Updated GitHub Action versions to the latest supported releases for improved stability and security.
  • Added a workflow step to print the image registry path, making it easier to identify the published image location during CI runs.

📦 Compatibility

  • Images are now available for both amd64 and arm64 architectures.

v0.0.6

25 Feb 21:00
3d03efe

Choose a tag to compare

🚀 Release Notes — v0.0.6

🔧 CI & Build

  • Migrated to golangci-lint v2 with caching
  • Improved GitHub Actions workflow (faster builds, cleaner job separation)
  • Docker push now configurable and skips gracefully if credentials are missing

🔐 Security

  • Improved path handling logic
  • Added tests for path validation
  • Updated gosec configuration to handle false positives

🐳 Docker

  • Switched to distroless base image
  • Built fully static binary (CGO_ENABLED=0, stripped flags)

📘 Docs

  • Updated README to reference v0.0.6 tag

Focus: CI reliability, performance improvements, container hardening, and minor security refinements.

v0.0.5

24 Feb 11:46
1d7f3b8

Choose a tag to compare

Fixes:

Corrected File Serving Priority Between filePath.html and filePath/index.html

  • The server now correctly prioritizes filePath.html if it exists.
  • If filePath.html does not exist but filePath/ is a directory, the server serves filePath/index.html.
  • If neither exists, the server returns 404 Not Found.

v0.0.4

19 Feb 09:51
20cc193

Choose a tag to compare

  1. Update gofr version to v1.34.0

v0.0.3

10 Feb 05:46
150f9b6

Choose a tag to compare

What's Changed

  • Exempt gofr's well-known endpoint in static server middleware.

Full Changelog: v0.0.2...v0.0.3

v0.0.2

09 Jan 15:46
24a9a10

Choose a tag to compare

Enhancements

  1. Removed File Mapping
    The server no longer creates a map of files, streamlining the file-serving process.

  2. 404 Status for Missing Files
    If a requested file is not found, the server now returns a 404 status code, improving error handling.

  3. Default Directory Update
    The default directory for serving static files has been changed to static.

    • To customize this directory set the STATIC_DIR_PATH environment variable.

v0.0.1

27 Nov 17:47
e58debd

Choose a tag to compare

Release Notes

  1. Create Static File Server which reads from website directory with the following support.
    • Re-direct to 404.html endpoint when webpage does not exist.
    • Add .html endpoint to urls which does not have any extension.