| 1 |
= cowboy_handler:terminate(3) |
| 2 |
|
| 3 |
== Name |
| 4 |
|
| 5 |
cowboy_handler:terminate - Terminate the handler |
| 6 |
|
| 7 |
== Description |
| 8 |
|
| 9 |
[source,erlang] |
| 10 |
---- |
| 11 |
terminate(Reason, PartialReq, State, Handler) -> ok |
| 12 |
|
| 13 |
Reason :: any() |
| 14 |
PartialReq :: map() |
| 15 |
State :: any() |
| 16 |
Handler :: module() |
| 17 |
---- |
| 18 |
|
| 19 |
Call the optional terminate callback if it is defined. |
| 20 |
|
| 21 |
Make sure to use this function at the end of the execution |
| 22 |
of modules that implement custom handler behaviors. |
| 23 |
|
| 24 |
== Arguments |
| 25 |
|
| 26 |
Reason:: |
| 27 |
|
| 28 |
Reason for termination. |
| 29 |
|
| 30 |
PartialReq:: |
| 31 |
|
| 32 |
The Req object. |
| 33 |
+ |
| 34 |
It is possible to remove fields from the Req object to save memory |
| 35 |
when the handler has no concept of requests/responses. The only |
| 36 |
requirement is that a map is provided. |
| 37 |
|
| 38 |
State:: |
| 39 |
|
| 40 |
Handler state. |
| 41 |
|
| 42 |
Handler:: |
| 43 |
|
| 44 |
Handler module. |
| 45 |
|
| 46 |
== Return value |
| 47 |
|
| 48 |
The atom `ok` is always returned. It can be safely ignored. |
| 49 |
|
| 50 |
== Changelog |
| 51 |
|
| 52 |
* *2.0*: Function introduced. |
| 53 |
|
| 54 |
== Examples |
| 55 |
|
| 56 |
.Terminate a handler normally |
| 57 |
[source,erlang] |
| 58 |
---- |
| 59 |
cowboy_handler:terminate(normal, Req, State, Handler). |
| 60 |
---- |
| 61 |
|
| 62 |
== See also |
| 63 |
|
| 64 |
link:man:cowboy_handler(3)[cowboy_handler(3)] |