Something went wrong. Try again.
A charm-like tui library
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637//! Per-connection context shared across middleware layers. Mirrors//! charmbracelet/ssh.Context — a place to stash request-scoped values that//! outlive a single middleware frame.//!//! Phase 0 keeps this minimal: just the auth state and a small kv map.//! Public-key, certificate, and cancel-channel surface land alongside the//! middleware framework in Phase 2.const Context = @This();
allocator: Allocator,authenticated: bool = false,user_name: []const u8 = "",remote_addr: []const u8 = "",client_version: []const u8 = "",values: StringHashMapUnmanaged([]const u8) = .empty,
pub fn init(allocator: Allocator) Context { return .{ .allocator = allocator };}
pub fn deinit(self: *Context) void { self.values.deinit(self.allocator); self.* = undefined;}
pub fn set(self: *Context, key: []const u8, value: []const u8) !void { try self.values.put(self.allocator, key, value);}
pub fn get(self: *const Context, key: []const u8) ?[]const u8 { return self.values.get(key);}
const std = @import("std");const Allocator = std.mem.Allocator;const StringHashMapUnmanaged = std.StringHashMapUnmanaged;