summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_filter.h
blob: d26ae1a988c74a4d488179aef13ced4673151993 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (C) Alejandro Colomar
 * Copyright (C) NGINX, Inc.
 */

#ifndef NXT_HTTP_FILTER_H_INCLUDED_
#define NXT_HTTP_FILTER_H_INCLUDED_


#include "nxt_router.h"

#include "nxt_auto_config.h"

#include <stddef.h>

#include "nxt_clang.h"
#include "nxt_errno.h"
#include "nxt_list.h"
#include "nxt_main.h"


typedef struct nxt_http_filter_handler_s  nxt_http_filter_handler_t;


struct nxt_http_filter_handler_s {
    nxt_work_handler_t              filter_handler;
    void                            *data;
};


nxt_inline nxt_int_t nxt_http_filter_handler_add(nxt_http_request_t *r,
    nxt_work_handler_t filter_handler, void *data);


nxt_inline nxt_int_t
nxt_http_filter_handler_add(nxt_http_request_t *r,
    nxt_work_handler_t filter_handler, void *data)
{
    nxt_http_filter_handler_t  *elem;

    elem = nxt_list_add(r->response_filters);
    if (nxt_slow_path(elem == NULL)) {
        return NXT_ERROR;
    }

    elem->filter_handler = filter_handler;
    elem->data = data;

    return NXT_OK;
}


#endif  /* NXT_HTTP_FILTER_H_INCLUDED_ */