From c20ec0c3434e57719d487a8628048188cf787ffb Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 12 Oct 2008 21:33:52 -0300 Subject: [PATCH] Frontend maps request to Atom ID before retrieving resource --- frontend/cgi/cgi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/cgi/cgi.c b/frontend/cgi/cgi.c index 069a073..736fb68 100644 --- a/frontend/cgi/cgi.c +++ b/frontend/cgi/cgi.c @@ -48,9 +48,22 @@ cgi_serve_request (AtomCtx *ctx) AtomID *id; AtomEntry *atom; AtomError *error; - id = atom_id_new (path); - atom = atom_retrieve_entry (ctx, id); - atom_id_delete (id); + char *req; + id = atom_id_new_from_frontend (ctx, path); + if (id == NULL || (req = atom_id_to_backend (ctx, id)) == NULL) + { + atom = NULL; + error = atom_error_new (); + atom_error_code_set (error, 404); + atom_error_message_set (error, "Resource not found"); + atom_error_set (ctx, error); + } + else + { + atom = atom_retrieve_entry (ctx, req); + } + if (id != NULL) + atom_id_delete (id); if (atom) { char * str; -- 2.20.1