# Outputs

* if the return value is `string` then it will send that string as the response's body.
* If it's an `int` then it will send it as a status code.
* If it's an `error` then it will set a bad request with that error as its reason.
* If it's an `error` and an `int` then the error code is the output integer instead of 400(bad request).
* If it's a custom `struct` then it sent as a JSON, when a Content-Type header is not already set.
* If it's a custom `struct` and a `string` then the second output value, string, it will be the Content-Type and so on.

| Type                                                                                   | Replies to                    |
| -------------------------------------------------------------------------------------- | ----------------------------- |
| string                                                                                 | body                          |
| string, string                                                                         | content-type, body            |
| string, int                                                                            | body, status code             |
| int                                                                                    | status code                   |
| int, string                                                                            | status code, body             |
| error                                                                                  | if not nil, bad request       |
| any, bool                                                                              | if false then fires not found |
| <Τ>                                                                                    | JSON body                     |
| <Τ>, string                                                                            | body, content-type            |
| <Τ>, error                                                                             | JSON body or bad request      |
| <Τ>, int                                                                               | JSON body, status code        |
| [Result](https://pkg.go.dev/github.com/kataras/iris/v12/hero#Result)                   | calls its `Dispatch` method   |
| [PreflightResult](https://pkg.go.dev/github.com/kataras/iris/v12/hero#PreflightResult) | calls its `Preflight` method  |

> Where `<T>` means any struct value.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://iris-go.gitbook.io/iris/dependency-injection/outputs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
