Skip to content

Commit

Permalink
docs: Rename controllers to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Dec 5, 2024
1 parent 4ed2b47 commit 4deaaae
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions documentation/docs/tutorials/02-crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ to play with data. It's a form of **dependency injection** that we chose to use
for the code generator of Fuego, but you can implement it in any way you want.

To implement the service, you need to slightly modify the
generated `controllers/books.go` and `main.go` files.
generated `controller/books.go` and `main.go` files.

```go title="controllers/books.go" {8-9,28-42} showLineNumbers
```go title="controller/books.go" {8-9,28-42} showLineNumbers
package controller

import (
Expand Down Expand Up @@ -79,16 +79,16 @@ import (
"github.com/go-fuego/fuego"

// ADD NEXT LINE
"hello-fuego/controllers"
"hello-fuego/controller"
)

func main() {
s := fuego.NewServer()
// ....

// Declare the resource
booksResources := controllers.BooksResources{
BooksService: controllers.RealBooksService{},
booksResources := controller.BooksResources{
BooksService: controller.RealBooksService{},
// Other services & dependencies, like a DB etc.
}

Expand Down Expand Up @@ -125,36 +125,36 @@ package main
import (
"github.com/go-fuego/fuego"

"hello-fuego/controllers"
"hello-fuego/controller"
)

func main() {
s := fuego.NewServer()

// List all books
fuego.Get(s, "/books", controllers.GetBooks)
fuego.Get(s, "/books", controller.GetBooks)

// Create a new book
fuego.Post(s, "/books", controllers.CreateBook)
fuego.Post(s, "/books", controller.CreateBook)

// Get a book by id
fuego.Get(s, "/books/:id", controllers.GetBook)
fuego.Get(s, "/books/:id", controller.GetBook)

// Update a book by id
fuego.Put(s, "/books/:id", controllers.UpdateBook)
fuego.Put(s, "/books/:id", controller.UpdateBook)

// Update a book by id
fuego.Patch(s, "/books/:id", controllers.UpdateBook)
fuego.Patch(s, "/books/:id", controller.UpdateBook)

// Delete a book by id
fuego.Delete(s, "/books/:id", controllers.DeleteBook)
fuego.Delete(s, "/books/:id", controller.DeleteBook)

s.Run()
}
```
```go title="controllers/books.go"
package controllers
```go title="controller/books.go"
package controller

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

0 comments on commit 4deaaae

Please sign in to comment.