mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 03:01:03 +01:00
3945fa68d1
We have to do the same on iris-contrib/examples, iris-contrib/middleware and e.t.c. Former-commit-id: 0860688158f374bc137bc934b81b26dcd0e10964
37 lines
645 B
Go
37 lines
645 B
Go
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
func newApp() *iris.Application {
|
|
app := iris.New()
|
|
app.Post("/", handler)
|
|
|
|
return app
|
|
}
|
|
|
|
// simple yaml stuff, read more at https://yaml.org/start.html
|
|
type product struct {
|
|
Invoice int `yaml:"invoice"`
|
|
Tax float32 `yaml:"tax"`
|
|
Total float32 `yaml:"total"`
|
|
Comments string `yaml:"comments"`
|
|
}
|
|
|
|
func handler(ctx iris.Context) {
|
|
var p product
|
|
if err := ctx.ReadYAML(&p); err != nil {
|
|
ctx.StatusCode(iris.StatusBadRequest)
|
|
ctx.WriteString(err.Error())
|
|
return
|
|
}
|
|
|
|
ctx.Writef("Received: %#+v", p)
|
|
}
|
|
|
|
func main() {
|
|
app := newApp()
|
|
app.Run(iris.Addr(":8080"))
|
|
}
|