https://github.com/mhutter/ffs
HTTP handler that serves static files from a given directory, but serves index.html if the requested file is not found.
https://github.com/mhutter/ffs
golang
Last synced: 11 months ago
JSON representation
HTTP handler that serves static files from a given directory, but serves index.html if the requested file is not found.
- Host: GitHub
- URL: https://github.com/mhutter/ffs
- Owner: mhutter
- Created: 2018-07-11T14:34:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-08-23T15:07:50.000Z (almost 4 years ago)
- Last Synced: 2025-03-23T19:17:59.349Z (over 1 year ago)
- Topics: golang
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FallbackFileServer
[](https://gowalker.org/github.com/mhutter/ffs)
HTTP handler that serves static files from a given directory, but serves `index.html` if the requested file is not found.
## Usage
Usage example using [mux][]
```go
r := mux.NewRouter()
r.PathPrefix("/api").Handler(api)
// Serve static assets
r.PathPrefix("/").
Handler(ffs.New(publicDir)).
Methods("GET")
```
[mux]: http://gorillatoolkit.org/pkg/mux
> [Manuel Hutter](https://hutter.io) -
> GitHub [@mhutter](https://github.com/mhutter) -
> Twitter [@dratir](https://twitter.com/dratir)