Skip to content

🚀 v3 Request: Merge static and filesystem middleware as static middleware #2031

@efectn

Description

@efectn

Feature Description

I think we should merge static and filesystem to make Fiber core simple in v3. Also there's no performance problem when we compare fasthttp.FS static and io/fs filesystem middleware. (#2027)

Additional Context (optional)

╭─efectn@tearch ~/v3 ‹v3-beta›
╰─$ wrk2 -t12 -c100 -d5s -R20000 http://127.0.0.1:3000/static
Running 5s test @ http://127.0.0.1:3000/static
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.09ms    0.94ms  22.08ms   93.45%
    Req/Sec       -nan      -nan   0.00      0.00%
  99642 requests in 5.00s, 54.54MB read
Requests/sec:  19934.28
Transfer/sec:     10.91MB
╭─efectn@tearch ~/v3 ‹v3-beta›
╰─$ wrk2 -t12 -c100 -d5s -R20000 http://127.0.0.1:3000/filesystem
Running 5s test @ http://127.0.0.1:3000/filesystem
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    17.42ms   33.75ms 264.19ms   88.56%
    Req/Sec       -nan      -nan   0.00      0.00%
  99428 requests in 5.00s, 53.29MB read
Requests/sec:  19892.46
Transfer/sec:     10.66MB
╭─efectn@tearch ~/v3 ‹v3-beta›
╰─$ wrk2 -t12 -c100 -d5s -R20000 http://127.0.0.1:3000/filesystem/test.txt
Running 5s test @ http://127.0.0.1:3000/filesystem/test.txt
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.53ms    2.15ms  44.67ms   94.69%
    Req/Sec       -nan      -nan   0.00      0.00%
  99646 requests in 5.00s, 14.35MB read
Requests/sec:  19929.40
Transfer/sec:      2.87MB
╭─efectn@tearch ~/v3 ‹v3-beta›
╰─$ wrk2 -t12 -c100 -d5s -R20000 http://127.0.0.1:3000/static/test.txt
Running 5s test @ http://127.0.0.1:3000/static/test.txt
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.10ms  837.88us  17.46ms   89.62%
    Req/Sec       -nan      -nan   0.00      0.00%
  99643 requests in 5.00s, 15.77MB read
Requests/sec:  19930.33
Transfer/sec:      3.16MB

Code Snippet (optional)

package  main

import  (
"log"
"os"

"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/filesystem"
)

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

	app.Use("/filesystem", filesystem.New(filesystem.Config{
		Root: os.DirFS("proxy"),
		Browse:  true,
	}))

	app.Static("/static",  "proxy", fiber.Static{
		Browse:  true,
	})
	log.Fatal(app.Listen(":3000"))
}

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests may be closed without explanation.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions