From 9789dabed48a6f11bccd679bd9e5ff446c2bc559 Mon Sep 17 00:00:00 2001 From: EwenQuim Date: Thu, 25 Jan 2024 18:07:54 +0100 Subject: [PATCH] readme: More simple example --- README.md | 21 +++++++++++++++++++++ examples/hello-world/main.go | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 examples/hello-world/main.go diff --git a/README.md b/README.md index 95ec7cd5..47f38bcd 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,25 @@ Chi, Gin, Fiber and Echo are great frameworks. But since they were designed a lo ```go package main +import "github.com/go-fuego/fuego" + +func main() { + s := fuego.NewServer() + + fuego.Get(s, "/", func(c fuego.Ctx[any]) (string, error) { + return "Hello, World!", nil + }) + + s.Run() +} +``` + +
+All features + +```go +package main + import ( "context" "errors" @@ -112,6 +131,8 @@ curl http://localhost:8088 -X POST -d '{"name": "Fuego"}' -H 'Content-Type: appl # {"error":"cannot transform request body: cannot transform request body: fuego is not a name"} ``` +
+ ## Contributing See the [contributing guide](CONTRIBUTING.md) diff --git a/examples/hello-world/main.go b/examples/hello-world/main.go new file mode 100644 index 00000000..c35a811f --- /dev/null +++ b/examples/hello-world/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + + "github.com/go-fuego/fuego" +) + +func main() { + fmt.Println("curl -X GET http://localhost:9999/") + fmt.Println("----------------------------------") + + s := fuego.NewServer() + + fuego.Get(s, "/", func(c fuego.Ctx[any]) (string, error) { + return "Hello, World!", nil + }) + + s.Run() +}