Commit Graph

42 Commits

Author SHA1 Message Date
Zhidao HONG
4735931ace Var: separating nxt_tstr_t from nxt_var_t.
It's for the introduction of njs support.
For each option that supports native variable and JS template literals introduced next,
it's unified as template string.

No functional changes.
2022-11-20 23:15:01 +08:00
Valentin Bartenev
ce26dd729e Implemented basic statistics API. 2022-08-29 14:27:09 +08:00
Zhidao HONG
45b89e3257 Var: dynamic variables support.
This commit adds the variables $arg_NAME, $header_NAME, and $cookie_NAME.
2022-07-14 04:32:49 +08:00
Andrew Clayton
4418f99cd4 Constified numerous function parameters.
As was pointed out by the cppcheck[0] static code analysis utility we
can mark numerous function parameters as 'const'. This acts as a hint to
the compiler about our intentions and the compiler will tell us when we
deviate from them.

[0]: https://cppcheck.sourceforge.io/
2022-06-22 00:30:44 +02:00
Alejandro Colomar
e525605d05 Added new array APIs that also work with non-arrays.
Similar to how C pointers to variables can always be considered as
pointers to the first element of an array of size 1 (see the
following code for an example of how they are equivalent),
treating non-NXT_CONF_VALUE_ARRAY as if they were
NXT_CONF_VALUE_ARRAYs of size 1 allows for simpler and more
generic code.

	void foo(ptrdiff_t sz, int arr[sz])
	{
		for (ptrdiff_t i = 0; i < sz; i++)
			arr[i] = 0;
	}

	void bar(void)
	{
		int  x;
		int  y[1];

		foo(1, &x);
		foo(1, y);
	}

nxt_conf_array_elements_count_or_1():
	Similar to nxt_conf_array_elements_count().
	Return a size of 1 when input is non-array, instead of
	causing undefined behavior.  That value (1) makes sense
	because it will be used as the limiter of a loop that
	loops over the array and calls
	nxt_conf_get_array_element_or_itself(), which will return
	a correct element for such loops.

nxt_conf_get_array_element_or_itself():
	Similar to nxt_conf_get_array_element().
	Return the input pointer unmodified (i.e., a pointer to
	the unique element of a hypothetical array), instead of
	returning NULL, which wasn't very useful.

nxt_conf_array_qsort():
	Since it's a no-op for non-arrays, this API can be reused.
2022-04-26 12:38:48 +02:00
Alejandro Colomar
940d695f82 Added 'const' for read-only function parameter.
That parameter is not being modified in the function.  Make it
'const' to allow passing 'static const' variables.
2022-04-26 12:38:48 +02:00
Zhidao HONG
5fa5b1464f Configuration: automatic migration to the new "share" behavior. 2021-10-09 10:44:31 +08:00
Valentin Bartenev
376d758dd7 PHP: implemented "targets" option.
This allows to specify multiple subsequent targets inside PHP applications.
For example:

  {
      "listeners": {
          "*:80": {
              "pass": "routes"
          }
      },

      "routes": [
          {
              "match": {
                  "uri": "/info"
              },

              "action": {
                  "pass": "applications/my_app/phpinfo"
              }
          },
          {
              "match": {
                  "uri": "/hello"
              },

              "action": {
                  "pass": "applications/my_app/hello"
              }
          },
          {
              "action": {
                  "pass": "applications/my_app/rest"
              }
          }
      ],

      "applications": {
          "my_app": {
              "type": "php",
              "targets": {
                  "phpinfo": {
                      "script": "phpinfo.php",
                      "root": "/www/data/admin",
                  },

                  "hello": {
                      "script": "hello.php",
                      "root": "/www/data/test",
                  },

                  "rest": {
                      "root": "/www/data/example.com",
                      "index": "index.php"
                  },
              }
          }
      }
  }
2020-05-14 13:15:01 +03:00
Valentin Bartenev
68c6b67ffc Configuration: support for rational numbers. 2020-03-30 19:37:58 +03:00
Tiago Natel
0beb8ea5e1 Fixed passing false in namespace flags.
This patch closes #328 in github.
2019-10-11 10:00:06 +00:00
Valentin Bartenev
08a8d1510d Basic support for serving static files. 2019-09-19 02:47:09 +03:00
Valentin Bartenev
6a6bc63c48 Configuration: support for POST operations on arrays.
It allows to add an array element without specifying the index.
2019-04-24 20:31:00 +03:00
Max Romanov
5bfdebb9e4 Introducing Java Servlet Container beta. 2019-02-28 18:02:42 +03:00
Igor Sysoev
ce650ea0f7 Introduced nxt_conf_array_qsort(). 2019-02-26 19:48:41 +03:00
Igor Sysoev
547082171e Introduced nxt_conf_array_elements_count(). 2019-02-26 19:48:38 +03:00
Valentin Bartenev
8d844bc2aa Controller: certificates storage interface. 2018-09-20 15:27:08 +03:00
Valentin Bartenev
2dfd8ffc2f Deduplicated string value initializations. 2018-09-20 15:27:06 +03:00
Valentin Bartenev
771dc2f55e Exported functions for accessing configuration values. 2018-06-07 16:17:30 +03:00
Max Romanov
9cd4fdbdb7 Introducing extended app process management.
- Pre-fork 'processes.spare' application processes;
- fork more processes to keep 'processes.spare' idle processes;
- fork on-demand up to 'processes.max' count;
- scale down idle application processes above 'processes.spare' after
  'processes.idle_timeout';
- number of concurrently started application processes also limited by
  'processes.spare' (or 1, if spare is 0).
2018-01-29 16:17:36 +03:00
Valentin Bartenev
1c6d4d8cff Basic validation errors. 2017-10-10 19:46:58 +03:00
Valentin Bartenev
1ba2f44ad9 Introduced nxt_conf_get_array_element(). 2017-08-16 15:45:38 +03:00
Valentin Bartenev
95907e2912 Object mapping interface extended with more string types. 2017-08-16 15:45:12 +03:00
Valentin Bartenev
80deee3903 Controller: more HTTP headers and detailed JSON parsing errors. 2017-08-11 19:54:40 +03:00
Valentin Bartenev
a6c4ef7a10 Configuration: reduced memory consumption of long strings. 2017-07-18 18:00:19 +03:00
Valentin Bartenev
eb4c2e4a21 Configuration: nxt_conf_map_object() improvements. 2017-07-10 17:55:51 +03:00
Valentin Bartenev
c9fbd832ab Controller: sending JSON configuration to router. 2017-07-06 22:52:05 +03:00
Valentin Bartenev
842aa9ab46 Configuration: basic validation of schema. 2017-07-05 18:44:43 +03:00
Igor Sysoev
f05d674126 Added nxt_msec_t element to nxt_conf_map_object(). 2017-06-29 19:26:32 +03:00
Valentin Bartenev
53074c3b29 Configuration: reduced names of structures, functions, and macros. 2017-06-28 18:56:33 +03:00
Igor Sysoev
ee381fcca1 JSON property iterator nxt_conf_json_object_next_member(). 2017-06-28 15:26:54 +03:00
Valentin Bartenev
f86c803098 Interface for mapping JSON configuration objects to C structures. 2017-06-26 21:41:58 +03:00
Valentin Bartenev
9399a04121 Configuration printing functions splitted in two parts.
Requested by Igor.
2017-06-23 23:28:37 +03:00
Valentin Bartenev
72429410f7 Renames and reordering of parameters in configuration parser functions.
Requested by Igor.
2017-06-23 20:54:07 +03:00
Igor Sysoev
f888a5310c Using new memory pool implementation. 2017-06-20 19:49:17 +03:00
Valentin Bartenev
c0bf729c8e Controller: support for partial PUT and DELETE operations. 2017-05-30 17:12:20 +03:00
Valentin Bartenev
5cca4b3ab7 Style and a trivial fix. 2017-05-26 20:30:51 +03:00
Valentin Bartenev
48155f3a49 Optimized internal representation of JSON objects and arrays. 2017-05-23 14:02:37 +03:00
Valentin Bartenev
c7be5bd6ae Controller: partial retrieving of configuration. 2017-05-18 20:40:19 +03:00
Valentin Bartenev
dc95b2f3de Controller: pretty-printing of JSON responses. 2017-05-16 22:02:01 +03:00
Valentin Bartenev
0ca2c2fce2 Controller: trivial abilities to save and request configuration.
Now you can get current configuration with:

   $ curl 127.0.0.1:8443

and put new configuration with:

   $ curl -X PUT -d @conf.json 127.0.0.1:8443
2017-05-15 22:39:53 +03:00
Valentin Bartenev
cddbab6312 JSON output in controller. 2017-04-11 00:29:47 +03:00
Valentin Bartenev
bf401fa544 JSON parsing in controller. 2017-04-10 17:06:22 +03:00