mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-04-19 08:36:50 +00:00
Add argument to change port
This commit is contained in:
parent
3460c7b815
commit
30c8af2cef
11
README.adoc
11
README.adoc
@ -4,6 +4,17 @@ Simple implementation of an identicon service.
|
||||
|
||||
== Usage
|
||||
|
||||
=== Start application
|
||||
|
||||
The application takes two optional arguments to specify the location of the config file and the port the application
|
||||
is listening. The following example shows the default values used if no arguments used.
|
||||
|
||||
....
|
||||
$ idicon -c /etc/idicon/config.toml -p 8000
|
||||
....
|
||||
|
||||
=== Client side
|
||||
|
||||
HTTP `GET` is used to request an identicon image.
|
||||
|
||||
....
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
@ -196,13 +197,15 @@ func configure(configFile string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
configFile := flag.String("c", "/etc/idicon/config.toml", "-c <path to config file>")
|
||||
configFile := flag.String("c", "/etc/idicon/config.toml", "path to config file")
|
||||
port := flag.Int("p", 8000, "server port")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
configure(*configFile)
|
||||
|
||||
router := mux.NewRouter()
|
||||
router.HandleFunc("/avatar/{id}", requestHandler)
|
||||
log.Println("Starting ...")
|
||||
log.Fatal(http.ListenAndServe(":8000", router))
|
||||
log.Println(fmt.Sprintf("Starting on port %d ...", *port))
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), router))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user