Skip to content

Commit

Permalink
Shorten Github issue template and add test example
Browse files Browse the repository at this point in the history
  • Loading branch information
aldas committed Nov 22, 2024
1 parent 118c163 commit 9e73691
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
31 changes: 20 additions & 11 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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)
}
}
```

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ package main
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"log/slog"
"net/http"
)

Expand All @@ -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
Expand Down

0 comments on commit 9e73691

Please sign in to comment.