2019-08-03 03:41:09 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12"
|
2019-08-03 03:41:09 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
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 {
|
2020-05-17 23:25:38 +02:00
|
|
|
ctx.StopWithError(iris.StatusBadRequest, err)
|
2019-08-03 03:41:09 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Writef("Received: %#+v", p)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := newApp()
|
2020-03-05 21:41:27 +01:00
|
|
|
app.Listen(":8080")
|
2019-08-03 03:41:09 +02:00
|
|
|
}
|