@@ -70,6 +70,8 @@ namespace mongo {
7070 string& responseMsg, int & responseCode,
7171 vector<string>& headers, const SockAddr &from ) {
7272
73+ DBDirectClient db ( txn );
74+
7375 string::size_type first = url.find ( " /" , 1 );
7476 if ( first == string::npos ) {
7577 responseCode = 400 ;
@@ -106,11 +108,11 @@ namespace mongo {
106108
107109 if ( method == " GET" ) {
108110 responseCode = 200 ;
109- html = handleRESTQuery ( fullns , action , params , responseCode , ss );
111+ html = handleRESTQuery ( db, fullns , action, params, responseCode, ss );
110112 }
111113 else if ( method == " POST" ) {
112114 responseCode = 201 ;
113- handlePost ( fullns , MiniWebServer::body ( rq ) , params , responseCode , ss );
115+ handlePost ( db, fullns , MiniWebServer::body ( rq ), params, responseCode, ss );
114116 }
115117 else {
116118 responseCode = 400 ;
@@ -127,7 +129,8 @@ namespace mongo {
127129 responseMsg = ss.str ();
128130 }
129131
130- bool handleRESTQuery ( const std::string& ns,
132+ bool handleRESTQuery ( DBDirectClient& db,
133+ const std::string& ns,
131134 const std::string& action,
132135 BSONObj & params,
133136 int & responseCode,
@@ -229,7 +232,8 @@ namespace mongo {
229232 }
230233
231234 // TODO Generate id and revision per couch POST spec
232- void handlePost ( const std::string& ns,
235+ void handlePost ( DBDirectClient& db,
236+ const std::string& ns,
233237 const char *body,
234238 BSONObj& params,
235239 int & responseCode,
@@ -256,8 +260,6 @@ namespace mongo {
256260 return def;
257261 }
258262
259- DBDirectClient db;
260-
261263 } restHandler;
262264
263265 bool RestAdminAccess::haveAdminUsers (OperationContext* txn) const {
0 commit comments