Commit 995534d
authored
Handle custom status code mappings for routing errors (#2101)
* Handle custom status code mappings for routing errors
Not all gRPC error codes and http status codes can have a one to one
mapping. Http can have both a path and a method component, while gRPC
will just have a function that is specific to the combination of method
and path when translating between the two. That means that for gRPC a
missing function simply means "unimplemented", while for the equivalent
REST API it is common to distinguish an unhandled method request on a
known resource as "Method Not Allowed" with the response code 405.
This may not be the only place where expectations of response codes
needed may not align with what is provided by the current mapping
chain http.Status* -> gRPC code.Codes -> http.Status*, where some
information may be lost in the double conversion.
As the error handler accepts an 'error' interface, it should be possible
to provide a custom error structure that can contain the http Status
code to wrap the original error to allow for the expected response code
to be provided without impacting the current function signatures.
* update with goimports
* Restore DefaultRoutingErrorHandler and tests, and update doc strings
Remove the customization from the DefaultRoutingErrorHandler as this is
what should be done by consumers, consequently remove the modifications
to tests affected.
Update doc strings as requested.
* Rename StatusHTTP to HTTPStatus
* Update names and docstrings
* Update customizing your gateway docs
* rework example
* remove newline1 parent 43cbfd2 commit 995534d
File tree
3 files changed
+63
-0
lines changed- docs/docs/mapping
- runtime
3 files changed
+63
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
| |||
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
75 | 91 | | |
76 | 92 | | |
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
82 | 103 | | |
83 | 104 | | |
84 | 105 | | |
| |||
119 | 140 | | |
120 | 141 | | |
121 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
122 | 147 | | |
123 | 148 | | |
124 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
0 commit comments