This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 56a10c9d712a97b5307f1e67cfb666c5f4ef7a4b
Author: Leif Hedstrom <[email protected]>
AuthorDate: Thu May 1 10:22:12 2025 -0700

    Add a StatusCode() macro for Cripts convenience mode (#12170)
    
    (cherry picked from commit 9ebd63943edc39dd5901afc0ed4c3437f231bedd)
---
 doc/developer-guide/cripts/cripts-convenience.en.rst | 5 +++++
 include/cripts/Preamble.hpp                          | 1 +
 2 files changed, 6 insertions(+)

diff --git a/doc/developer-guide/cripts/cripts-convenience.en.rst 
b/doc/developer-guide/cripts/cripts-convenience.en.rst
index cb2fc4010c..cc479b79e9 100644
--- a/doc/developer-guide/cripts/cripts-convenience.en.rst
+++ b/doc/developer-guide/cripts/cripts-convenience.en.rst
@@ -118,6 +118,7 @@ Macro                         Traditional API equivalent
 ===========================   
====================================================================
 ``Regex(name, ...)``          ``static cripts::Matcher::PCRE name(...)``
 ``ACL(name, ...)``            ``static cripts::Matcher::Range::IP name(...)``
+``StatusCode(code, ...)``     ``cripts::Error::Status::Set(code, ...)``
 ``CreateCounter(id, name)``   ``instance.metrics[id] = 
cripts::Metrics::Counter::Create(name)``
 ``CreateGauge(id, name)``     ``instance.metrics[id] = 
cripts::Metrics::Gauge::Create(name)``
 ``FilePath(name, path)``      ``static const cripts::File::Path name(path)``
@@ -138,3 +139,7 @@ An example of using ACLs and regular expressions:
        // do something
      }
    }
+.. note::
+   The ``StatusCode`` macro currently only works with the status code, the 
reason
+   message can not be set or overridden. Fixing this will require a future 
change
+   in the Traffic Server code base.
diff --git a/include/cripts/Preamble.hpp b/include/cripts/Preamble.hpp
index 9f92fa958e..5c61d469d9 100644
--- a/include/cripts/Preamble.hpp
+++ b/include/cripts/Preamble.hpp
@@ -116,6 +116,7 @@ extern cripts::Versions version; // Access to the ATS 
version information
 #define urls                        context->_urls
 #define Regex(_name_, ...)          static cripts::Matcher::PCRE 
_name_(__VA_ARGS__);
 #define ACL(_name_, ...)            static cripts::Matcher::Range::IP 
_name_(__VA_ARGS__);
+#define StatusCode(_name_, ...)     cripts::Error::Status::Set(_name_, 
__VA_ARGS__);
 #define CreateCounter(_id_, _name_) instance.metrics[_id_] = 
cripts::Metrics::Counter::Create(_name_);
 #define CreateGauge(_id_, _name_)   instance.metrics[_id_] = 
cripts::Metrics::Gauge::Create(_name_);
 #define FilePath(_name_, _path_)    static const cripts::File::Path 
_name_(_path_);

Reply via email to