iris/_examples/dependency-injection/basic/main.go
2020-04-08 20:04:56 +03:00

28 lines
391 B
Go

package main
import "github.com/kataras/iris/v12"
type (
testInput struct {
Email string `json:"email"`
}
testOutput struct {
ID int `json:"id"`
Name string `json:"name"`
}
)
func handler(id int, in testInput) testOutput {
return testOutput{
ID: id,
Name: in.Email,
}
}
func main() {
app := iris.New()
app.DI().Post("/{id:int}", handler)
app.Listen(":8080")
}