mirror of
https://github.com/labstack/echo.git
synced 2025-05-27 23:07:33 +02:00
Shorten Github issue template and add test example
This commit is contained in:
parent
118c1632f2
commit
9e73691837
35
.github/ISSUE_TEMPLATE.md
vendored
35
.github/ISSUE_TEMPLATE.md
vendored
@ -1,23 +1,32 @@
|
|||||||
### Issue Description
|
### Issue Description
|
||||||
|
|
||||||
### Checklist
|
|
||||||
|
|
||||||
- [ ] Dependencies installed
|
|
||||||
- [ ] No typos
|
|
||||||
- [ ] Searched existing issues and docs
|
|
||||||
|
|
||||||
### Expected behaviour
|
|
||||||
|
|
||||||
### Actual behaviour
|
|
||||||
|
|
||||||
### Steps to reproduce
|
|
||||||
|
|
||||||
### Working code to debug
|
### Working code to debug
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
import (
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestExample(t *testing.T) {
|
||||||
|
e := echo.New()
|
||||||
|
|
||||||
|
e.GET("/", func(c echo.Context) error {
|
||||||
|
return c.String(http.StatusOK, "Hello, World!")
|
||||||
|
})
|
||||||
|
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
|
||||||
|
e.ServeHTTP(rec, req)
|
||||||
|
|
||||||
|
if rec.Code != http.StatusOK {
|
||||||
|
t.Errorf("got %d, want %d", rec.Code, http.StatusOK)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -90,7 +91,9 @@ func main() {
|
|||||||
e.GET("/", hello)
|
e.GET("/", hello)
|
||||||
|
|
||||||
// Start server
|
// 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
|
// Handler
|
||||||
|
Loading…
x
Reference in New Issue
Block a user