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

static file always return 404 even if get the correct response body #68

Open
xy6321 opened this issue May 23, 2024 · 0 comments
Open

static file always return 404 even if get the correct response body #68

xy6321 opened this issue May 23, 2024 · 0 comments

Comments

@xy6321
Copy link

xy6321 commented May 23, 2024

Let me simplify the code

package main

import (
	"net/http"
	"time"

	"github.com/gin-contrib/timeout"
	"github.com/gin-gonic/gin"
)

func timeoutMiddleware() gin.HandlerFunc {
	return timeout.New(
		timeout.WithTimeout(500*time.Millisecond),
		timeout.WithHandler(func(c *gin.Context) {
			c.Next()
		}),
		timeout.WithResponse(func(c *gin.Context) {
			c.String(http.StatusRequestTimeout, "timeout")
		}),
	)
}

func main() {
	gin.SetMode(gin.ReleaseMode)
	r := gin.New()

	r.Use(timeoutMiddleware())
	r.Static("/log", "./")
	r.Run(":8888")
}

When i try to get http://localhost:8888/log/go.sum
i can get correct file content in response body but http status code is 404
image

go version go1.21.5 linux/amd64

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

1 participant