Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
hadisfr committed Jan 8, 2019
1 parent 4c88557 commit 6490672
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions examples/handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using namespace std;

Response* RandomNumberHandler::callback(Request *req) {
Response *RandomNumberHandler::callback(Request *req) {
Response *res = new Response;
res->setHeader("Content-Type", "text/html");
string body;
Expand All @@ -24,7 +24,7 @@ Response* RandomNumberHandler::callback(Request *req) {
return res;
}

Response* LoginHandler::callback(Request *req) {
Response *LoginHandler::callback(Request *req) {
string username = req->getBodyParam("username");
string password = req->getBodyParam("password");
cout << "username: " << username << ",\tpassword: " << password << endl;
Expand All @@ -33,10 +33,10 @@ Response* LoginHandler::callback(Request *req) {
return res;
}

Response* UploadHandler::callback(Request *req) {
Response *UploadHandler::callback(Request *req) {
string name = req->getBodyParam("file_name");
string file = req->getBodyParam("file");
cout << name << ":\n" << file << endl;
Response *res = Response::redirect("/");
return res;
}
}
11 changes: 5 additions & 6 deletions examples/handlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
#include <ctime> // for time
#include <iostream>


class RandomNumberHandler : public RequestHandler {
public:
Response* callback(Request*);
Response *callback(Request *);
};

class LoginHandler : public RequestHandler {
public:
Response* callback(Request*);
Response *callback(Request *);
};

class UploadHandler : public RequestHandler {
public:
Response* callback(Request*);
};
public:
Response *callback(Request *);
};
2 changes: 1 addition & 1 deletion examples/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "my_server.hpp"
#include "handlers.hpp"
#include "my_server.hpp"
#include <cstdlib> // for rand and srand
#include <ctime> // for time
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion examples/my_server.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "my_server.hpp"

MyServer::MyServer(): Server(){}
MyServer::MyServer() : Server() {}
2 changes: 1 addition & 1 deletion examples/my_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
class MyServer : public Server {
public:
MyServer();
};
};
6 changes: 2 additions & 4 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,21 @@ void Server::run() {

const char *Server::Exception::getMessage() { return pMessage; }


ShowFile::ShowFile(string _filePath, string _fileType) {
filePath = _filePath;
fileType = _fileType;
}

Response *ShowFile::callback(Request *req) {
cout<<"---------------------------------------"<<endl;
cout << "---------------------------------------" << endl;
Response *res = new Response;
res->setHeader("Content-Type", fileType);
res->setBody(readFile(filePath.c_str()));
return res;
}

ShowPage::ShowPage(string filePath)
: ShowFile(filePath, "text/" + getExtension(filePath)) {
}
: ShowFile(filePath, "text/" + getExtension(filePath)) {}

ShowImage::ShowImage(string filePath)
: ShowFile(filePath, "image/" + getExtension(filePath)) {}
1 change: 1 addition & 0 deletions server/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RequestHandler {
class ShowFile : public RequestHandler {
std::string filePath;
std::string fileType;

public:
ShowFile(std::string filePath, std::string fileType);
Response *callback(Request *req);
Expand Down

0 comments on commit 6490672

Please sign in to comment.