()
| 356 | } |
| 357 | |
| 358 | func ExampleRequest_Error() { |
| 359 | handler := func(req micro.Request) { |
| 360 | // respond with an error |
| 361 | // Error sets Nats-Service-Error and Nats-Service-Error-Code headers in the response |
| 362 | if err := req.Error("400", "bad request", []byte(`{"error": "value should be a number"}`)); err != nil { |
| 363 | log.Fatal(err) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | fmt.Printf("%T", handler) |
| 368 | } |