Skip to content

Commit

Permalink
readme: More simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Jan 25, 2024
1 parent 6af6488 commit 9789dab
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
```

<details>
<summary>All features</summary>

```go
package main

import (
"context"
"errors"
Expand Down Expand Up @@ -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"}
```

</details>

## Contributing

See the [contributing guide](CONTRIBUTING.md)
Expand Down
20 changes: 20 additions & 0 deletions examples/hello-world/main.go
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit 9789dab

Please sign in to comment.