@@ -8,33 +8,44 @@ Final modification of `Problem` responses before HTTP response.
88
99Problem4J provides a ** post-processing mechanism** that allows modifying certain fields of a ` Problem ` object after it
1010has been constructed. This feature makes it possible to generate environment-dependent or runtime-resolved URIs for
11- fields such as ` "type" ` and ` "instance" ` , without embedding such logic into exception classes or resolvers.
11+ fields such as ` "type" ` , ` "title" ` , and ` "instance" ` , without embedding such logic into exception classes or resolvers.
1212
1313Currently, the following fields can be overridden:
1414
1515- ` type ` - the logical category of the problem
16+ - ` title ` - a short, human-readable summary of the problem
1617- ` instance ` - an identifier of a specific occurrence, often a URI or trace reference
1718
1819These overrides are applied by a ** global post-processor** using templates defined in configuration properties.
1920Templates for overriding problem fields may include placeholders that are dynamically replaced at runtime.
2021
21- Available placeholders include :
22+ Available placeholders:
2223
2324- for overriding ` "type" ` field:
2425 - ` {problem.type} ` - the original ` "type" ` value of the problem
25- - for overriding "instance" field:
26+ - ` {context.<key>} ` - any value from the current request context (e.g. ` {context.traceId} ` )
27+ - for overriding ` "title" ` field:
28+ - ` {problem.title} ` - the original ` "title" ` value of the problem
29+ - ` {context.<key>} ` - any value from the current request context
30+ - for overriding ` "instance" ` field:
2631 - ` {problem.instance} ` - the original ` "instance" ` value of the problem
27- - ` {context.traceId} ` - the trace identifier from the current request (if tracing is enabled)
32+ - ` {context.<key>} ` - any value from the current request context (e.g. ` {context.traceId} ` )
33+
34+ The ` {context.<key>} ` placeholder resolves values stored in ` ProblemContext ` for the current request. The built-in
35+ [ Simple Tracing] ( ./additional-features#simple-tracing ) feature stores the trace identifier under the ` traceId ` key,
36+ making it available as ` {context.traceId} ` . You can also populate the context with custom keys by providing your own
37+ ` ProblemContextFilter ` .
2838
2939General post-processing rules:
3040
3141- Overrides are applied ** only if all placeholders in the template can be resolved** :
3242 - ` {problem.type} ` - applied if the original ` type ` is ** non-null** , ** non-empty** , not ` "about:blank" ` .
43+ - ` {problem.title} ` - applied if the original ` title ` is ** non-null** and ** non-empty** .
3344 - ` {problem.instance} ` - applied if the original ` instance ` is ** non-null** and ** non-empty** .
34- - ` {context.traceId } ` - applied if the context provides a ** non-null** , ** non-empty** trace ID .
45+ - ` {context.<key> } ` - applied if the context provides a ** non-null** , ** non-empty** value for that key .
3546- If any referenced placeholder cannot be resolved, ** the override is skipped** (occurrences of unknown placeholders
3647 also abort the override for that field).
37- - The resulting values are ** non-empty strings** and treated as valid URIs.
48+ - The resulting values are ** non-empty strings** and treated as valid URIs (for ` type ` and ` instance ` ) .
3849- If no override is set, fields remain as in the original ` Problem ` .
3950- ** Static templates** (no placeholders) are always applied, regardless of the original value.
4051
@@ -43,6 +54,7 @@ These rules ensure that field transformation is safe and predictable while allow
4354Available configuration properties:
4455
4556- [ ` problem4j.type-override ` ] ( ./setting-up-and-configuration#problem4jtype-override )
57+ - [ ` problem4j.title-override ` ] ( ./setting-up-and-configuration#problem4jtitle-override )
4658- [ ` problem4j.instance-override ` ] ( ./setting-up-and-configuration#problem4jinstance-override )
4759
4860** Example:**
0 commit comments