xref: /unit/src/nodejs/unit-http/unit.h (revision 1020)
1802Salexander.borisov@nginx.com 
2802Salexander.borisov@nginx.com /*
3802Salexander.borisov@nginx.com  * Copyright (C) NGINX, Inc.
4802Salexander.borisov@nginx.com  */
5802Salexander.borisov@nginx.com 
6802Salexander.borisov@nginx.com #ifndef _NXT_NODEJS_UNIT_H_INCLUDED_
7802Salexander.borisov@nginx.com #define _NXT_NODEJS_UNIT_H_INCLUDED_
8802Salexander.borisov@nginx.com 
9*1020Smax.romanov@nginx.com #include "nxt_napi.h"
10802Salexander.borisov@nginx.com 
11878Salexander.borisov@nginx.com 
12*1020Smax.romanov@nginx.com class Unit : public nxt_napi {
13802Salexander.borisov@nginx.com public:
14802Salexander.borisov@nginx.com     static napi_value init(napi_env env, napi_value exports);
15802Salexander.borisov@nginx.com 
16802Salexander.borisov@nginx.com private:
17*1020Smax.romanov@nginx.com     Unit(napi_env env, napi_value jsthis);
18802Salexander.borisov@nginx.com     ~Unit();
19802Salexander.borisov@nginx.com 
20802Salexander.borisov@nginx.com     static napi_value create(napi_env env, napi_callback_info info);
21802Salexander.borisov@nginx.com     static void destroy(napi_env env, void *nativeObject, void *finalize_hint);
22802Salexander.borisov@nginx.com 
23802Salexander.borisov@nginx.com     static napi_value create_server(napi_env env, napi_callback_info info);
24802Salexander.borisov@nginx.com     static napi_value listen(napi_env env, napi_callback_info info);
25828Salexander.borisov@nginx.com     static napi_value _read(napi_env env, napi_callback_info info);
26802Salexander.borisov@nginx.com     static void request_handler(nxt_unit_request_info_t *req);
27828Salexander.borisov@nginx.com     static int add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port);
28828Salexander.borisov@nginx.com     static void remove_port(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id);
29842Salexander.borisov@nginx.com     static void quit(nxt_unit_ctx_t *ctx);
30802Salexander.borisov@nginx.com 
31802Salexander.borisov@nginx.com     napi_value get_server_object();
32802Salexander.borisov@nginx.com 
33802Salexander.borisov@nginx.com     napi_value create_socket(napi_value server_obj,
34802Salexander.borisov@nginx.com                              nxt_unit_request_info_t *req);
35802Salexander.borisov@nginx.com 
36802Salexander.borisov@nginx.com     napi_value create_request(napi_value server_obj, napi_value socket);
37802Salexander.borisov@nginx.com 
38802Salexander.borisov@nginx.com     napi_value create_response(napi_value server_obj, napi_value socket,
39802Salexander.borisov@nginx.com                                napi_value request,
40*1020Smax.romanov@nginx.com                                nxt_unit_request_info_t *req);
41802Salexander.borisov@nginx.com 
42802Salexander.borisov@nginx.com     static napi_value response_send_headers(napi_env env,
43802Salexander.borisov@nginx.com                                             napi_callback_info info);
44802Salexander.borisov@nginx.com 
45802Salexander.borisov@nginx.com     static napi_value response_write(napi_env env, napi_callback_info info);
46802Salexander.borisov@nginx.com     static napi_value response_end(napi_env env, napi_callback_info info);
47802Salexander.borisov@nginx.com 
48*1020Smax.romanov@nginx.com     void create_headers(nxt_unit_request_info_t *req, napi_value request);
49802Salexander.borisov@nginx.com 
50*1020Smax.romanov@nginx.com     void append_header(nxt_unit_field_t *f, napi_value headers,
51802Salexander.borisov@nginx.com                                      napi_value raw_headers, uint32_t idx);
52802Salexander.borisov@nginx.com 
53802Salexander.borisov@nginx.com     static napi_ref constructor_;
54802Salexander.borisov@nginx.com 
55802Salexander.borisov@nginx.com     napi_ref        wrapper_;
56802Salexander.borisov@nginx.com     nxt_unit_ctx_t  *unit_ctx_;
57802Salexander.borisov@nginx.com };
58802Salexander.borisov@nginx.com 
59802Salexander.borisov@nginx.com 
60*1020Smax.romanov@nginx.com #endif /* _NXT_NODEJS_UNIT_H_INCLUDED_ */
61