mirror of
				https://github.com/pcvolkmer/idicon.git
				synced 2025-10-31 10:06:12 +00:00 
			
		
		
		
	Add argument to change port
This commit is contained in:
		
							
								
								
									
										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)) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user