mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
@@ -5,6 +5,7 @@ const Ctx = server.Cmd;
|
||||
const browser = @import("browser.zig").browser;
|
||||
const target = @import("target.zig").target;
|
||||
const page = @import("page.zig").page;
|
||||
const log = @import("log.zig").log;
|
||||
|
||||
pub const Error = error{
|
||||
UnknonwDomain,
|
||||
@@ -26,6 +27,7 @@ const Domains = enum {
|
||||
Browser,
|
||||
Target,
|
||||
Page,
|
||||
Log,
|
||||
};
|
||||
|
||||
// The caller is responsible for calling `free` on the returned slice.
|
||||
@@ -55,6 +57,7 @@ pub fn do(
|
||||
.Browser => browser(alloc, id, iter.next().?, &scanner, ctx),
|
||||
.Target => target(alloc, id, iter.next().?, &scanner, ctx),
|
||||
.Page => page(alloc, id, iter.next().?, &scanner, ctx),
|
||||
.Log => log(alloc, id, iter.next().?, &scanner, ctx),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
34
src/cdp/log.zig
Normal file
34
src/cdp/log.zig
Normal file
@@ -0,0 +1,34 @@
|
||||
const std = @import("std");
|
||||
|
||||
const server = @import("../server.zig");
|
||||
const Ctx = server.Cmd;
|
||||
const result = @import("cdp.zig").result;
|
||||
const getParams = @import("cdp.zig").getParams;
|
||||
const stringify = @import("cdp.zig").stringify;
|
||||
|
||||
const LogMethods = enum {
|
||||
enable,
|
||||
};
|
||||
|
||||
pub fn log(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
action: []const u8,
|
||||
scanner: *std.json.Scanner,
|
||||
ctx: *Ctx,
|
||||
) ![]const u8 {
|
||||
const method = std.meta.stringToEnum(LogMethods, action) orelse
|
||||
return error.UnknownMethod;
|
||||
return switch (method) {
|
||||
.enable => enable(alloc, id, scanner, ctx),
|
||||
};
|
||||
}
|
||||
|
||||
fn enable(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
_: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
return result(alloc, id, null, null);
|
||||
}
|
||||
Reference in New Issue
Block a user