| 11 | const string kPath = "/sudoku/"; |
| 12 | |
| 13 | void onRequest(const TcpConnectionPtr& conn, |
| 14 | FastCgiCodec::ParamMap& params, |
| 15 | Buffer* in) |
| 16 | { |
| 17 | string uri = params["REQUEST_URI"]; |
| 18 | LOG_INFO << conn->name() << ": " << uri; |
| 19 | |
| 20 | for (FastCgiCodec::ParamMap::const_iterator it = params.begin(); |
| 21 | it != params.end(); ++it) |
| 22 | { |
| 23 | LOG_DEBUG << it->first << " = " << it->second; |
| 24 | } |
| 25 | if (in->readableBytes() > 0) |
| 26 | LOG_DEBUG << "stdin " << in->retrieveAllAsString(); |
| 27 | Buffer response; |
| 28 | response.append("Context-Type: text/plain\r\n\r\n"); |
| 29 | if (uri.size() == kCells + kPath.size() && uri.find(kPath) == 0) |
| 30 | { |
| 31 | response.append(solveSudoku(uri.substr(kPath.size()))); |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | // FIXME: set http status code 400 |
| 36 | response.append("bad request"); |
| 37 | } |
| 38 | |
| 39 | FastCgiCodec::respond(&response); |
| 40 | conn->send(&response); |
| 41 | } |
| 42 | |
| 43 | void onConnection(const TcpConnectionPtr& conn) |
| 44 | { |
nothing calls this directly
no test coverage detected