github.com/zak-blake/goa@v1.4.1/middleware/README.md (about)

     1  # goa Middlewares
     2  
     3  The `middleware` package provides middlewares that do not depend on additional packages other than
     4  the ones already used by `goa`. These middlewares provide functionality that is useful to most
     5  microservices:
     6  
     7  * [LogRequest](https://goa.design/reference/goa/middleware#LogRequest) enables logging of
     8    incoming requests and corresponding responses. The log format is entirely configurable. The default
     9    format logs the request HTTP method, path and parameters as well as the corresponding
    10    action and controller names. It also logs the request duration and response length. It also logs
    11    the request payload if the DEBUG log level is enabled. Finally if the RequestID middleware is
    12    mounted LogRequest logs the unique request ID with each log entry.
    13  
    14  * [LogResponse](https://goa.design/reference/goa/middleware#LogResponse) logs the content
    15    of the response body if the DEBUG log level is enabled.
    16  
    17  * [RequestID](https://goa.design/reference/goa/middleware#RequestID) injects a unique ID
    18    in the request context. This ID is used by the logger and can be used by controller actions as
    19    well. The middleware looks for the ID in the [RequestIDHeader](https://goa.design/reference/goa/middleware#RequestIDHeader)
    20    header and if not found creates one.
    21  
    22  * [Recover](https://goa.design/reference/goa/middleware#Recover) recover panics and logs
    23    the panic object and backtrace.
    24  
    25  * [Timeout](https://goa.design/reference/goa/middleware#Timeout) sets a deadline in the
    26    request context. Controller actions may subscribe to the context channel to get notified when
    27    the timeout expires.
    28  
    29  * [RequireHeader](https://goa.design/reference/goa/middleware#RequireHeader) checks for the
    30    presence of a header in the request with a value matching a given regular expression. If the
    31    header is absent or does not match the regexp the middleware sends a HTTP response with a given
    32    HTTP status.
    33  
    34  Other middlewares listed below are provided as separate Go packages.
    35  
    36  #### Gzip
    37  
    38  Package [gzip](https://goa.design/reference/goa/middleware/gzip.html) contributed by
    39  [@tylerb](https://github.com/tylerb) adds the ability to compress response bodies using gzip format
    40  as specified in RFC 1952.
    41  
    42  #### Security
    43  
    44  package [security](https://goa.design/reference/goa/middleware/security.html) contains middleware
    45  that should be used in conjunction with the security DSL.