mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
README: minor
This commit is contained in:
parent
22a89c12cb
commit
613d3fc749
33
README.md
33
README.md
|
@ -92,6 +92,39 @@ func create(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**MVC** equivalent:
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "github.com/kataras/iris/v12/mvc"
|
||||||
|
```
|
||||||
|
|
||||||
|
```go
|
||||||
|
m := mvc.New(booksAPI)
|
||||||
|
m.Handle(new(BookController))
|
||||||
|
```
|
||||||
|
|
||||||
|
```go
|
||||||
|
type BookController struct {
|
||||||
|
/* dependencies */
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: http://localhost:8080/books
|
||||||
|
func (c *BookController) Get() []Book {
|
||||||
|
return []Book{
|
||||||
|
{"Mastering Concurrency in Go"},
|
||||||
|
{"Go Design Patterns"},
|
||||||
|
{"Black Hat Go"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: http://localhost:8080/books
|
||||||
|
func (c *BookController) Post(b Book) int {
|
||||||
|
println("Received Book: " + b.Title)
|
||||||
|
|
||||||
|
return iris.StatusCreated
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
**Run** your Iris web server:
|
**Run** your Iris web server:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
Loading…
Reference in New Issue
Block a user