pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/labstack/echo/discussions/2848

n="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-6534fbc3f5e83ac0.css" /> Dynamic Data with Static Middleware · labstack/echo · Discussion #2848 · GitHub
Skip to content
Discussion options

You must be logged in to vote

Do you want to create SPA (single-page-application) where application checks if request path exists and serves that static file or if it does not will reserve index.html as fallback?

There are many ways to achieve this, one is to have Filesystem that falls back to index.html which is served from in-memory fs

package main

import (
	"embed"
	"fmt"
	"io/fs"
	"log/slog"
	"net/http"
	"strings"

	"github.com/labstack/echo/v5"
	"github.com/spf13/afero"
)

//go:embed dist/public
var distAssets embed.FS

type overlayFS struct {
	primary  fs.FS
	fallback fs.FS
}

func (o overlayFS) Open(name string) (fs.File, error) {
	if name == "index.html" {
		return o.fallback.Open(name)
	}
	f, err := o.primary.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kaaax0815
Comment options

@aldas
Comment options

aldas Feb 2, 2026
Maintainer

Answer selected by kaaax0815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy