zynagent-first application framework

Back to the API reference

zyn.HttpError#

/// A framework-generated HTTP failure whose representation may be replaced.
pub const HttpError = struct {
    pub const Source = http_error_source.Source;

    status: std.http.Status,
    source: Source,
    formats: []const Request.Format,
    request_id: Request.Id,
    method: @FieldType(Request, "method"),
    url: @FieldType(Request, "url"),

    pub fn render(
        self: *HttpError,
        comptime template_name: []const u8,
        params: anytype,
    ) !Response;

    pub fn html(self: *HttpError, body: []const u8) !Response;

    pub fn text(self: *HttpError, body: []const u8) !Response;

    pub fn json(self: *HttpError, value: anytype) !Response;

    pub fn xml(self: *HttpError, body: []const u8) !Response;

    pub fn markdown(self: *HttpError, body: []const u8) !Response;

    pub fn bytes(self: *HttpError, body: []const u8, content_type: []const u8) !Response;
};