Assignment 2: Personalized Time Server

This assignment extends your time server from assignment 1 to print a more personalized message for logged-in users. You will build your understanding of the go language and its standard library, as well as begin using source code management.

Start by placing your solution1 to Assignment 1 under git. You will develop your solution to assignment 2 from that starting point.

While developing your solution, you will make periodic check-ins as you reach minor milestone objectives. Use your judgement as to what constitutes appropriate checkpoints, but at least some intermediate milestones are expected.

URLs

You personalized time server will support the following URLs:

HTML Snippets

Login Form

<html>
<body>
<form action="login">
  What is your name, Earthling?
  <input type="text" name="name" size="50">
  <input type="submit">
</form>
</p>
</body>
</html>

Logged-Out Page

Note the meta tag:

<html>
<head>
<META http-equiv="refresh" content="10;URL=/">
<body>
<p>Good-bye.</p>
</body>
</html>

Concurrency

Since this program is a web server, you can expect that the library will be multi-threaded to be able to handle multiple concurrent requests. Since any of those requests may update the map of cookies to name, you will have to protect map accesses using a reader/writer mutex from the sync package.

uuidgen

To obtain a universally unique identifier for the cookie, use the Golang os/exec package to run the external command /usr/bin/uuidgen.

Normally, you would use a cryptographic hash to obscure the information in the cookie, but that is overkill for the purposes of this assignment.

Log Messages

Log messages are used essentially for three purposes:

  1. revenue generation: some events, such as "user clicked on ad" may trigger money changing hands and need to be kept in an audit trail
  2. trend analysis & resource planning
  3. debugging

Print each HTTP request to standard output (one per line). When running the server, you will invoke it with a shell command that redirects output to a file.

You may, additionally, print any debugging messages to standard error. This is not required, but if you do have debugging print statements, leave them in when you submit your solution. Chances are, you may find yourself neeeding those messages again.

UTC Time

While you're developing the the personal time server, assume that your simple time server is still in production.

Your PHB asks you to interrupt your work on personal time server and modify simple time server to print out the local time plus UTC time:

The time is now 4:57:11 PM (23:57:11 UTC).

To get a more realistic sense of the process, perform this step after you've made substantial progress on the personalized time server.

Create a git branch named assignment-01 off of your assignment 1 solution and implement UTC time on the branch.

Don't forget to update the version number (-V flag).

Git

You should do local commits relatively frequently, as soon as you have any partial functionality implemented. Typically, a implementation of a program feature may involve multiple commits to the local repository with less-frequent pushes to the origin server when features are complete.

Tag each release with the version number to be printed by the -V flag, and bump the version for each milestone or release.

Create an annotated tag assignment-02.rcnn for the commit version you wish to hand in. Number the release candidates sequentially.

Do not be surprised if it takes several tries to get the final version. Just when you think you have the release ready to go out the door, you will often find one more tee to dot or eye to cross6. Be careful to avoid introducing regressions at this late stage of development. you will not be penalized if you have multiple release candidates: only the final RC submitted will be graded. Two digits should be plenty: if you have 100 release candidates, something is seriously out of whack.

Hand-In

Create a git bare repository by cloning your workspace and submit a compressed tarball. Your instructor will copy the repository and check out the HEAD. The README file should contain instructions on how to proceed. Don't forget to include a build script or makefile.

Footnotes