This is a simple webserver which simply sends redirects for a predefined list of URLs and logs them and keeps a counter of hits.
This is a simple webserver which will send redirects and keep logs and counters about the hits. It will read the "path to URL" mappings from a file and for each hit, it will log a record in MongoDB (containing path, time, referer, IP and userg agent) and will increment the counter "hit:path" (where path is the actual path) in Redis.
This is the Go implementation of the server, and it's part of a project which aims at implementing the same server in multiple languages/frameworks/backends for benchmarking using more realistic workloads.
It depends on the following go modules:
- github.com/mikejs/gomongo/mongo
- my fork of redis.go
Also you need, of course, MongoDB and Redis.
You need to invoke the webserver as: ws map_file [pool_size]
map_file contains the URLs to redirect. Its format is one entry
per line, local path and destination URL are separated by spaces,
like this:
test1 http://www.example.com/file1.html
It will redirect http://localhost/test1 to
http://www.example.com/file1.html
pool_size is the maximum number of connections to the databases.
You also need to create the database "logs" in MongoDB.