Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Serve assets files from embedded resources #209

Closed
Shareed2k opened this issue Mar 5, 2020 · 5 comments
Closed

🔥 Serve assets files from embedded resources #209

Shareed2k opened this issue Mar 5, 2020 · 5 comments

Comments

@Shareed2k
Copy link
Contributor

Is your feature request related to a problem?
there is no options to create one binary file with all assets

Describe the solution you'd like
i want to use something like http.FileServer, to use libs like [go.rice, pkger...]

@welcome
Copy link

welcome bot commented Mar 5, 2020

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template!

@koddr
Copy link

koddr commented Mar 6, 2020

@Shareed2k hi!

Try to use https://github.com/markbates/pkger by Mark Bates

@Shareed2k
Copy link
Contributor Author

Shareed2k commented Mar 6, 2020

Ok I found an ugly way to work with pkger.

handler := fasthttpadaptor.NewFastHTTPHandler(
	http.StripPrefix(
		"/console",
		handlers.CompressHandler(
			http.FileServer(pkger.Dir("/ui/build")),
		),
	),
)

m.core.Server.
	Use(func() func(*fiber.Ctx) {
		return func(c *fiber.Ctx) {
			// Only allow GET & HEAD methods
			if (c.Method() == http.MethodGet || c.Method() == http.MethodHead) && strings.HasPrefix(c.Path(), "/console") {
				handler(c.Fasthttp)
			}

			c.Next()
		}
	}())

@Fenny
Copy link
Member

Fenny commented Mar 8, 2020

We could create a middleware for pkger, I will take a closer look next week and see if its possible for v1.8.3

@Fenny Fenny changed the title Serve assets files from embedded resources 🔥 🔥 Serve assets files from embedded resources Mar 14, 2020
@Fenny
Copy link
Member

Fenny commented Apr 20, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants