mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
60 lines
1.8 KiB
Zig
60 lines
1.8 KiB
Zig
// Copyright (C) 2023-2024 Lightpanda (Selecy SAS)
|
|
//
|
|
// Francis Bouvier <francis@lightpanda.io>
|
|
// Pierre Tachoire <pierre@lightpanda.io>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
const std = @import("std");
|
|
|
|
const server = @import("../server.zig");
|
|
const Ctx = server.Ctx;
|
|
const cdp = @import("cdp.zig");
|
|
const result = cdp.result;
|
|
const IncomingMessage = @import("msg.zig").IncomingMessage;
|
|
const Input = @import("msg.zig").Input;
|
|
const stringify = cdp.stringify;
|
|
|
|
const log_cdp = std.log.scoped(.cdp);
|
|
|
|
const Methods = enum {
|
|
enable,
|
|
};
|
|
|
|
pub fn log(
|
|
alloc: std.mem.Allocator,
|
|
msg: *IncomingMessage,
|
|
action: []const u8,
|
|
ctx: *Ctx,
|
|
) ![]const u8 {
|
|
const method = std.meta.stringToEnum(Methods, action) orelse
|
|
return error.UnknownMethod;
|
|
|
|
return switch (method) {
|
|
.enable => enable(alloc, msg, ctx),
|
|
};
|
|
}
|
|
|
|
fn enable(
|
|
alloc: std.mem.Allocator,
|
|
msg: *IncomingMessage,
|
|
_: *Ctx,
|
|
) ![]const u8 {
|
|
const input = try Input(void).get(alloc, msg);
|
|
defer input.deinit();
|
|
log_cdp.debug("Req > id {d}, method {s}", .{ input.id, "log.enable" });
|
|
|
|
return result(alloc, input.id, null, null, input.sessionId);
|
|
}
|