mirror of
https://github.com/labstack/echo.git
synced 2025-02-15 13:53:06 +02:00
Adds example to readme (#1044)
This commit is contained in:
parent
2769113edf
commit
65f3fcbfe2
31
README.md
31
README.md
@ -30,6 +30,37 @@
|
|||||||
|
|
||||||
## [Get Started](https://echo.labstack.com/guide)
|
## [Get Started](https://echo.labstack.com/guide)
|
||||||
|
|
||||||
|
### Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/labstack/echo"
|
||||||
|
"github.com/labstack/echo/middleware"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Echo instance
|
||||||
|
e := echo.New()
|
||||||
|
// Middleware
|
||||||
|
e.Use(middleware.Logger())
|
||||||
|
e.Use(middleware.Recover())
|
||||||
|
// Routes
|
||||||
|
e.GET("/", hello)
|
||||||
|
// Start server
|
||||||
|
e.Logger.Fatal(e.Start(":1323"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handler
|
||||||
|
func hello(c echo.Context) error {
|
||||||
|
return c.String(http.StatusOK, "Hello, World!")
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Support Us
|
## Support Us
|
||||||
|
|
||||||
- :star: the project
|
- :star: the project
|
||||||
|
Loading…
x
Reference in New Issue
Block a user