Skip to content

Commit

Permalink
chore: update the documentation according to the new import style
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille authored and EwenQuim committed Sep 1, 2024
1 parent 4b668b4 commit df1b3c5
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ package main

import (
"net/http"

"github.com/go-fuego/fuego"
)

Expand Down Expand Up @@ -211,8 +212,9 @@ import (
"strings"

chiMiddleware "github.com/go-chi/chi/v5/middleware"
"github.com/go-fuego/fuego"
"github.com/rs/cors"

"github.com/go-fuego/fuego"
)

type Received struct {
Expand Down
6 changes: 4 additions & 2 deletions documentation/docs/guides/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ You can add middlewares to the whole server using the `Use` method:
package main

import (
"github.com/go-fuego/fuego"
"net/http"

"github.com/go-fuego/fuego"
)

func main() {
Expand Down Expand Up @@ -48,8 +49,9 @@ You can also add middlewares to a group of routes using the `Group` method:
package main

import (
"github.com/go-fuego/fuego"
"net/http"

"github.com/go-fuego/fuego"
)

func main() {
Expand Down
2 changes: 2 additions & 0 deletions documentation/docs/guides/openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ import (
"net/http"

httpSwagger "github.com/swaggo/http-swagger"

"github.com/go-fuego/fuego"
)

func openApiHandler(specURL string) http.Handler {
Expand Down
38 changes: 26 additions & 12 deletions documentation/docs/guides/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ func main() {
You can change the address of the server with the `WithAddr` option.

```go
s := fuego.NewServer(
fuego.WithAddr("localhost:8080"),
)
import "github.com/go-fuego/fuego"

func main() {
s := fuego.NewServer(
fuego.WithAddr("localhost:8080"),
)
}
```

### Port (Deprecated)
Expand All @@ -44,9 +48,13 @@ s := fuego.NewServer(
You can change the port of the server with the `WithPort` option.

```go
s := fuego.NewServer(
fuego.WithPort(8080),
)
import "github.com/go-fuego/fuego"

func main() {
s := fuego.NewServer(
fuego.WithPort(8080),
)
}
```

### CORS
Expand All @@ -58,12 +66,18 @@ because it applies on routes that aren't registered. For example,
but it's a request that needs to be handled by the CORS middleware.

```go
import "github.com/rs/cors"
import (
"github.com/rs/cors"

s := fuego.NewServer(
fuego.WithCorsMiddleware(cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
}).Handler),
"github.com/go-fuego/fuego"
)

func main() {
s := fuego.NewServer(
fuego.WithCorsMiddleware(cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
}).Handler),
)
}
```
3 changes: 2 additions & 1 deletion documentation/docs/guides/serialization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ package main
import (
"net/http"

"github.com/go-fuego/fuego"
jsoniter "github.com/json-iterator/go"

"github.com/go-fuego/fuego"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary
Expand Down
1 change: 1 addition & 0 deletions documentation/docs/guides/transformation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package main
import (
"context"
"strings"

"github.com/go-fuego/fuego"
)

Expand Down
6 changes: 4 additions & 2 deletions documentation/docs/tutorials/02-crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ func (s RealBooksService) GetBooks(id string) (Books, error) {
package main

import (
"github.com/go-fuego/fuego"

// ADD NEXT LINE
"hello-fuego/controllers"
"github.com/go-fuego/fuego"
)

func main() {
Expand Down Expand Up @@ -105,8 +106,9 @@ that can generates CRUD routes and controllers for you!
package main

import (
"hello-fuego/controllers"
"github.com/go-fuego/fuego"

"hello-fuego/controllers"
)

func main() {
Expand Down
5 changes: 5 additions & 0 deletions documentation/docs/tutorials/rendering/gomponents.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Just use the `fuego.Gomponent` type as a return type for your handler,
and return the gomponent.

```go
import (
"github.com/go-fuego/fuego"
"github.com/go-fuego/fuego/examples/full-app-gourmet/store"
)

// highlight-next-line
func (rs Ressource) adminIngredients(c fuego.ContextNoBody) (fuego.Gomponent, error) {
searchParams := components.SearchParams{
Expand Down
5 changes: 5 additions & 0 deletions documentation/docs/tutorials/rendering/std.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Just use the `fuego.HTML` type as a return type for your handler, and return
`c.Render()` with the template name and data.

```go
import (
"github.com/go-fuego/fuego"
"github.com/go-fuego/fuego/examples/full-app-gourmet/store/types"
)

// highlight-next-line
func (rs Ressource) unitPreselected(c fuego.ContextNoBody) (fuego.HTML, error) {
id := c.QueryParam("IngredientID")
Expand Down
5 changes: 5 additions & 0 deletions documentation/docs/tutorials/rendering/templ.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ with the `fuego.Templ` return type.
Example from [a recipe app](https://github.com/go-fuego/fuego/tree/main/examples/full-app-gourmet):

```go
import (
"github.com/go-fuego/fuego"
"github.com/go-fuego/fuego/examples/full-app-gourmet/store"
)

// highlight-next-line
func (rs Ressource) adminIngredients(c fuego.ContextNoBody) (fuego.Templ, error) {
searchParams := components.SearchParams{
Expand Down

0 comments on commit df1b3c5

Please sign in to comment.