mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 07:04:08 +00:00
15 lines
545 B
Zig
15 lines
545 B
Zig
const std = @import("std");
|
|
const zap = @import("zap");
|
|
|
|
/// A simple endpoint listening on the /error route that causes an error on GET
|
|
/// requests, which gets logged to the response (=browser) by default
|
|
pub const ErrorEndpoint = @This();
|
|
|
|
path: []const u8 = "/error",
|
|
error_strategy: zap.Endpoint.ErrorStrategy = .log_to_response,
|
|
|
|
pub fn get(_: *ErrorEndpoint, _: zap.Request) !void {
|
|
// error_strategy is set to .log_to_response
|
|
// --> this error will be shown in the browser, with a nice error trace
|
|
return error.@"Oh-no!";
|
|
}
|