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

🚀 feat: filesystem middleware work routes with params #977

Merged
merged 4 commits into from
Oct 29, 2020

Conversation

renanbastos93
Copy link
Member

Based on a user's request on issue #834 then was implemented now we have a new method called SendFile on filesystem middleware.

package main

import (
	"net/http"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/filesystem"
	"github.com/gofiber/fiber/v2/middleware/logger"
)

func main() {
	app := fiber.New()

	app.Use(logger.New())

	app.Use("/:path", func(c *fiber.Ctx) error {
		return filesystem.SendFile(c, http.Dir("./assets"), c.Params("path")+".html")
	})

	app.Listen(":3000")
}

@Fenny
Copy link
Member

Fenny commented Oct 28, 2020

@arsmn, looks good?

@renanbastos93
Copy link
Member Author

@gofiber/maintainers any more comments? or can I merge it?

@Fenny Fenny merged commit 1001fb5 into master Oct 29, 2020
@renanbastos93 renanbastos93 deleted the feat-fs-sendfile branch October 29, 2020 12:10
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

Successfully merging this pull request may close these issues.

🐛 filesystem middleware doesn't work for routes with params
3 participants