mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
added skeleton for App.zig
This commit is contained in:
parent
7f61b821d3
commit
ad2b2f2eb0
1 changed files with 34 additions and 0 deletions
34
src/App.zig
Normal file
34
src/App.zig
Normal file
|
@ -0,0 +1,34 @@
|
|||
//! WIP: zap.App.
|
||||
//!
|
||||
//! - Per Request Arena(s) thread-local?
|
||||
//! - Custom "State" Context, type-safe
|
||||
//! - route handlers
|
||||
//! - automatic error catching & logging, optional report to HTML
|
||||
|
||||
const std = @import("std");
|
||||
const zap = @import("zap.zig");
|
||||
|
||||
pub const Opts = struct {
|
||||
request_error_strategy: enum {
|
||||
/// log errors to console
|
||||
log_to_console,
|
||||
/// log errors to console AND generate a HTML response
|
||||
log_to_response,
|
||||
/// raise errors -> TODO: clarify: where can they be caught? in App.run()
|
||||
raise,
|
||||
},
|
||||
};
|
||||
|
||||
threadlocal var arena: ?std.heap.ArenaAllocator = null;
|
||||
|
||||
pub fn create(comptime Context: type, context: *Context, opts: Opts) type {
|
||||
return struct {
|
||||
context: *Context = context,
|
||||
error_strategy: @TypeOf(opts.request_error_strategy) = opts.request_error_strategy,
|
||||
endpoints: std.StringArrayHashMapUnmanaged(*zap.Endpoint.Wrapper.Internal) = .empty,
|
||||
|
||||
// pub fn addEndpoint(slug: []const u8, endpoint: anytype) !zap.Endpoint {
|
||||
// // TODO: inspect endpoint: does it have
|
||||
// }
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue