Permalink
Browse files

Add GET handler for _session

Send back an "Admin Party"-like response on a GET
request to /_session. This makes CouchApps work
that rely on _session (like Mobile Futon).
  • Loading branch information...
1 parent 6cc2407 commit 7509e3e8b5f0c520d32711a80e02fc16eb55f542 @vmx committed Mar 25, 2012
@@ -134,6 +134,16 @@ public void testServer() {
responseBody.put("version", TDRouter.getVersionString());
send(server, "GET", "/", TDStatus.OK, responseBody);
+ Map<String,Object> session = new HashMap<String,Object>();
+ Map<String,Object> userCtx = new HashMap<String,Object>();
+ List<String> roles = new ArrayList<String>();
+ roles.add("_admin");
+ session.put("ok", true);
+ userCtx.put("name", null);
+ userCtx.put("roles", roles);
+ session.put("userCtx", userCtx);
+ send(server, "GET", "/_session", TDStatus.OK, session);
+
List<String> allDbs = new ArrayList<String>();
send(server, "GET", "/_all_dbs", TDStatus.OK, allDbs);
@@ -457,6 +457,19 @@ public TDStatus do_GET_all_dbs(TDDatabase _db, String _docID, String _attachment
return new TDStatus(TDStatus.OK);
}
+ public TDStatus do_GET_session(TDDatabase _db, String _docID, String _attachmentName) {
+ // Send back an "Admin Party"-like response
+ Map<String,Object> session= new HashMap<String,Object>();
+ Map<String,Object> userCtx = new HashMap<String,Object>();
+ String[] roles = {"_admin"};
+ session.put("ok", true);
+ userCtx.put("name", null);
+ userCtx.put("roles", roles);
+ session.put("userCtx", userCtx);
+ connection.setResponseBody(new TDBody(session));
+ return new TDStatus(TDStatus.OK);
+ }
+
public TDStatus do_POST_replicate(TDDatabase _db, String _docID, String _attachmentName) {
// Extract the parameters from the JSON request body:
// http://wiki.apache.org/couchdb/Replication

0 comments on commit 7509e3e

Please sign in to comment.