diff of 146cb9fc3ce1eec473eeb864420e716a2689ee15

146cb9fc3ce1eec473eeb864420e716a2689ee15
diff --git a/src/middleware/json.lisp b/src/middleware/json.lisp
index ab95f21..9041b3e 100644
--- a/src/middleware/json.lisp
+++ b/src/middleware/json.lisp
@@ -5,4 +5,8 @@
 
 (defun @json (next)
   (setf (hunchentoot:content-type*) "application/json")
-  (funcall next))
+  (let ((result (funcall next)))
+    (if result
+	result
+	(progn (setf (hunchentoot:return-code*) 404) ""))))
+	
diff --git a/src/posts/post-db.lisp b/src/posts/post-db.lisp
index a763e39..28b1bc9 100644
--- a/src/posts/post-db.lisp
+++ b/src/posts/post-db.lisp
@@ -36,8 +36,10 @@
 	    resulting-page)))
 
 (defun get-post (id &key allow-hidden?)
-  (let ((post (aref (get-by-id* id allow-hidden?) 0)))
-    (fix-post post)))
+  (let* ((posts (coerce (get-by-id* id allow-hidden?) 'list))
+	 (post (first posts)))
+    (when post
+      (fix-post post))))
     
 (defun get-post-version (id version)
   (let ((post (first (coerce (get-versioned-by-id* id version) 'list))))
diff --git a/src/routes/post-routes.lisp b/src/routes/post-routes.lisp
index 236be96..e4579d1 100644
--- a/src/routes/post-routes.lisp
+++ b/src/routes/post-routes.lisp
@@ -44,8 +44,9 @@
   
   (let* ((show-hidden? (string= hidden "true"))
 	 (post (get-post id :allow-hidden? show-hidden?)))
-    (log:info "returning post (hidden allowed? ~a) { ~{~a~%~} }~%" hidden (alexandria:hash-table-alist post))
-    (stringify post)))
+    (when post
+      (log:info "returning post (hidden allowed? ~a) { ~{~a~%~} }~%" hidden (alexandria:hash-table-alist post))
+      (stringify post))))
 
 (defroute get-post-version-route ("/api/posts/post/:id/version/:version" :method :get
 								   :decorators (@json
diff --git a/src/routes/root-routes.lisp b/src/routes/root-routes.lisp
index 92a414e..3317e61 100644
--- a/src/routes/root-routes.lisp
+++ b/src/routes/root-routes.lisp
@@ -106,3 +106,6 @@
 
 (defroute post-view ("/blog/post/:id" :method :get) ()
   *root*)
+
+(defroute edit ("/blog/post/edit/:id" :method :get) ()
+  *root*)