-
to build the webserver
$ make compile_webserver
-
to run
$ sudo ./webserver example_config
-
clean up
make clean
- run unit tests (add sudo if not write permission)
$ make run_all_tests
- run test coverage (gcov) (depends on success of
$ make run_all_tests
)
$ make run_test_coverage
- run integration test
$ make run_integration_test
-
Config Format
see example_config
Currently, all path must be of one word;
"/" will give index page (not implemented yet); -
Creating Handlers
Important function that parses config:get_server_parameters
inserver.cc
Handlers are created and stored in a member variable inclass Server
calleduri2handler
,
which is a std::map from uri to handler pointer. e.g. "/static" -> Hander_Static -
Connections
Each connection is separated into a new thread.
Inserver.cc
, functionServer::run_server()
will spawnServer::session(socket_ptr sock)
into a new thread. -
Handling Requests
Request are received inServer::session(socket_ptr sock)
in each separate thread.
The uri is parsered in to "head" and "tail". (see additional methods inclass Request
inrequest_handler.h
)
e.g. "/static/foo/bar" => "/static" + "/foo/bar".
"head" is used to find the corresponding handler, by looking it up inuri2handler
(files are read into memory at once, need to consider large files later) -
Logging
Implemented using singleton,Logger
.
The methodget_statusPage
will generate a simple html status page as a string.
-
Build Docker Image
make build_docker_image
-
Deploy to AWS
$ ./deploy_aws.sh
-
Send request to server instance on AWS
e.g.$ http://54.183.253.238:2020/status
-
Demo Assignment 9
$ http://54.183.253.238:2020/static/features.md