Step 0: You need to install Go to work with the assignment.
Step 1:
You need to add directory into .bash_profile
(for OS X environment) or .bashrc
to let the compiler knows where to find the dependencies
export PATH=$PATH:/usr/local/go/bin # making sure go is on path
export GOPATH=<path-to-repo>
export PATH=$PATH:$GOPATH/bin
example:
export GOPATH=/[The directory you put this folder]/Project-1/
export PATH=$PATH:$GOPATH/bin
^ you need to add these lines in your .bashrc file and
source .bashrc
to activate them.
Step 2: When you run your code, we are currently using the run-server.sh script. It basically runs a immediate compilation and looks for dependency. You will encounter errors like:
cannot find package "github.com/go-ini/ini" in any of:
/usr/local/go/src/github.com/go-ini/ini (from $GOROOT)
/Desktop/Project-1/src/github.com/go-ini/ini (from $GOPATH)
That's because we usually don't include the dependency directory into our repository. Thus, we need to download the dependency. example:
go get github.com/go-ini/ini
Step 3: Now, you should be able to run the script.
run-server.sh [config_file]
In the config file, under the [httpd] section, set
Understand the starter code and explore Go's internal http web server.
The server program starts in
src/main/main.go
This package contains the skeleton code for developing the tritonhttp web server. You need to implement the methods which have panic("todo - methodName")
as their body.
httpd_structs.go
has the structures that can be used to initialize the new serverhttpd_server.go
has the skeleton methods for initializing and starting the new serverhttp_request_handler.go
has the skeleton methods for handling an incoming connection and subsequent requestshttp_response_handler.go
has the skeleton methods for handling various types of responses based on the requestserver_utils.go
has utility functions
Follow the testing strategies linked from the project description
For Simple testing :
-
Set
use_default_server=false
in the config file and start the server usingrun-server.sh [config_file] [hosts.json]
. -
Once the server is launched, test it's functionality using a browser, curl, netcat or a custom client.
-
The directories
sample_htdocs
andsample_htdocs_2
(populated with some sample files) has been provided in the starter code to help with testing. Verify the TritonHTTP server's functionality by accessing the files in this directory, and the reason we provide two directories is so you can test virtual hosting.