diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ee6f33ef8..82220c0a1 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,23 +1,32 @@ ### Issue Description -### Checklist +### Working code to debug -- [ ] Dependencies installed -- [ ] No typos -- [ ] Searched existing issues and docs +```go +package main -### Expected behaviour +import ( + "github.com/labstack/echo/v4" + "net/http" + "net/http/httptest" + "testing" +) -### Actual behaviour +func TestExample(t *testing.T) { + e := echo.New() -### Steps to reproduce + e.GET("/", func(c echo.Context) error { + return c.String(http.StatusOK, "Hello, World!") + }) -### Working code to debug + req := httptest.NewRequest(http.MethodGet, "/", nil) + rec := httptest.NewRecorder() -```go -package main + e.ServeHTTP(rec, req) -func main() { + if rec.Code != http.StatusOK { + t.Errorf("got %d, want %d", rec.Code, http.StatusOK) + } } ``` diff --git a/README.md b/README.md index fa2863bab..5381898d9 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ package main import ( "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "log/slog" "net/http" ) @@ -90,7 +91,9 @@ func main() { e.GET("/", hello) // Start server - e.Logger.Fatal(e.Start(":1323")) + if err := e.Start(":8080"); err != nil && !errors.Is(err, http.ErrServerClosed) { + slog.Error("failed to start server", "error", err) + } } // Handler