diff options
author | Russell King <rmk@armlinux.org.uk> | 2021-09-11 12:25:36 +0100 |
---|---|---|
committer | Russell King <rmk@armlinux.org.uk> | 2021-09-11 12:25:36 +0100 |
commit | acc52e700121120726b42a6dadd8c12f030ba349 (patch) | |
tree | 6310eccc6ac9dfad9f060670c9efc7c0420bdc5b /event-httpd.c | |
parent | 6201a11f03fe988a599a54f73c76640cac7e006e (diff) |
resource: split resource operations from resource object structure
Move the resource operations out of the resource object structure
and make them const.
Signed-off-by: Russell King <rmk@armlinux.org.uk>
Diffstat (limited to 'event-httpd.c')
-rw-r--r-- | event-httpd.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/event-httpd.c b/event-httpd.c index 1492fe4..27590dd 100644 --- a/event-httpd.c +++ b/event-httpd.c @@ -83,8 +83,8 @@ static void finish(GObject *source, GAsyncResult *res, gpointer user_data) g_data_input_stream_read_line_finish(c->data, res, &len, &error); - if (c->resource->close) { - c->resource->close(c, c->resource); + if (c->resource->ops->close) { + c->resource->ops->close(c, c->resource); c->resource = NULL; } @@ -106,7 +106,7 @@ static void update(GObject *source, GAsyncResult *res, gpointer user_data) return; } - c->resource->update(c, c->resource, line); + c->resource->ops->update(c, c->resource, line); g_free(line); @@ -227,17 +227,22 @@ static void receive(GObject *source, GAsyncResult *res, gpointer user_data) } c->resource = resource; + if (!resource->ops) { + respond_error(c, 204, "No Content"); + close_client(c); + return; + } // We have a valid resource, start the response switch (method) { case GET: - if (!resource->get) { + if (!resource->ops->get) { respond_error(c, 204, "No Content"); close_client(c); return; } - if (resource->get(c, resource)) { + if (resource->ops->get(c, resource)) { g_data_input_stream_read_line_async(c->data, 0, NULL, finish, c); } else { @@ -246,7 +251,7 @@ static void receive(GObject *source, GAsyncResult *res, gpointer user_data) break; case UPDATE: - if (!resource->update) { + if (!resource->ops->update) { respond_error(c, 204, "No Content"); close_client(c); return; |