Skip to content

Commit 9ebd639

Browse files
authored
Add a StatusCode() macro for Cripts convenience mode (#12170)
1 parent db850f1 commit 9ebd639

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

doc/developer-guide/cripts/cripts-convenience.en.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Macro Traditional API equivalent
118118
=========================== ====================================================================
119119
``Regex(name, ...)`` ``static cripts::Matcher::PCRE name(...)``
120120
``ACL(name, ...)`` ``static cripts::Matcher::Range::IP name(...)``
121+
``StatusCode(code, ...)`` ``cripts::Error::Status::Set(code, ...)``
121122
``CreateCounter(id, name)`` ``instance.metrics[id] = cripts::Metrics::Counter::Create(name)``
122123
``CreateGauge(id, name)`` ``instance.metrics[id] = cripts::Metrics::Gauge::Create(name)``
123124
``FilePath(name, path)`` ``static const cripts::File::Path name(path)``
@@ -138,3 +139,7 @@ An example of using ACLs and regular expressions:
138139
// do something
139140
}
140141
}
142+
.. note::
143+
The ``StatusCode`` macro currently only works with the status code, the reason
144+
message can not be set or overridden. Fixing this will require a future change
145+
in the Traffic Server code base.

include/cripts/Preamble.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ extern cripts::Versions version; // Access to the ATS version information
116116
#define urls context->_urls
117117
#define Regex(_name_, ...) static cripts::Matcher::PCRE _name_(__VA_ARGS__);
118118
#define ACL(_name_, ...) static cripts::Matcher::Range::IP _name_(__VA_ARGS__);
119+
#define StatusCode(_name_, ...) cripts::Error::Status::Set(_name_, __VA_ARGS__);
119120
#define CreateCounter(_id_, _name_) instance.metrics[_id_] = cripts::Metrics::Counter::Create(_name_);
120121
#define CreateGauge(_id_, _name_) instance.metrics[_id_] = cripts::Metrics::Gauge::Create(_name_);
121122
#define FilePath(_name_, _path_) static const cripts::File::Path _name_(_path_);

0 commit comments

Comments
 (0)