1
1
= nng_http_handler_set_tree(3http)
2
- //
3
- // Copyright 2018 Staysail Systems, Inc. <[email protected] >
2
+
3
+ // Copyright 2020 Staysail Systems, Inc. <[email protected] >
4
4
// Copyright 2018 Capitar IT Group BV <[email protected] >
5
5
// Copyright 2020 Dirac Research <[email protected] >
6
6
//
7
7
// This document is supplied under the terms of the MIT License, a
8
8
// copy of which should be located in the distribution where this
9
9
// file was obtained (LICENSE.txt). A copy of the license may also be
10
10
// found online at https://opensource.org/licenses/MIT.
11
- //
12
11
13
12
== NAME
14
13
15
14
nng_http_handler_set_tree - set HTTP handler to match trees
16
15
17
16
== SYNOPSIS
18
17
19
- [source, c]
18
+ [source,c]
20
19
----
21
20
#include <nng/nng.h>
22
21
#include <nng/supplemental/http/http.h>
@@ -28,18 +27,27 @@ int nng_http_handler_set_tree_exclusive(nng_http_handler *handler);
28
27
29
28
== DESCRIPTION
30
29
31
- The `nng_http_handler_set_tree()` function causes the _handler_ to be
32
- matched if the Request URI sent by the client is a logical child of
33
- the path for _handler_ .
30
+ The `nng_http_handler_set_tree()` function causes the _handler_ to be matched if the request URI sent
31
+ by the client is a logical child of the path for _handler_, and no more specific
32
+ _handler_ has been registered .
34
33
35
34
The `nng_http_handler_set_tree_exclusive()` function is similar to `nng_http_server_set_tree()`
36
- with the distinction that the _handler_ will be considered to *exclusively* handling its
37
- Request URI. Other handlers will be tested against _handler_ when being added to a server,
38
- possibly resulting in a URI conflict error.
35
+ with the distinction that the _handler_ will be considered to *exclusively* handle its request URI.
36
+ Unlike `nng_http_server_set_tree()`, it will not be possible to register additional
37
+ handlers in logical subdirectories of _handler_.
38
+
39
+ This is useful in cases when the handler would like to examine the entire path
40
+ and possibly behave differently; for example a REST API that uses the rest of
41
+ the path to pass additional parameters.
39
42
40
43
TIP: These methods are useful when constructing API handlers where a single
41
44
service address (path) supports dynamically generated children.
42
45
46
+ TIP: The non-exclusive form is also useful for providing a default handler to be
47
+ generated when a more specific child does not exist.
48
+ This can provide a better experience for users than the standard 404 error
49
+ handling.
50
+
43
51
== RETURN VALUES
44
52
45
53
This function returns 0 on success, and non-zero otherwise.
0 commit comments