Skip to content
Download

Next

mach::Next

Invokes the next middleware in the pipeline.

#include <mach/middleware/Next.hpp>
class Next {
public:
explicit Next(std::function<void()> next);
Next(const Next&) = delete;
Next& operator=(const Next&) = delete;
void operator()();
};
Name Description
operator() Invokes the next step in the middleware pipeline.

Not thread-safe. Concurrent access to the same Next instance must be synchronized externally.

  • Next instances are provided by Mach during middleware execution.
  • A Next instance is valid only for the duration of the current middleware invocation.
  • Each Next instance may be invoked at most once.
class LoggingMiddleware {
public:
void invoke(mach::Context& context, mach::Next& next) {
logger.info("Handling request.");
next();
logger.info("Request completed.");
}
};
Name Description
Context Provides access to the current HTTP request and response.