mirror of
				https://github.com/pcvolkmer/idicon.git
				synced 2025-10-31 01:56:13 +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 | == 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. | HTTP `GET` is used to request an identicon image. | ||||||
|  |  | ||||||
| .... | .... | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import ( | |||||||
| 	"crypto/md5" | 	"crypto/md5" | ||||||
| 	"encoding/hex" | 	"encoding/hex" | ||||||
| 	"flag" | 	"flag" | ||||||
|  | 	"fmt" | ||||||
| 	"image" | 	"image" | ||||||
| 	"image/color" | 	"image/color" | ||||||
| 	"image/draw" | 	"image/draw" | ||||||
| @@ -196,13 +197,15 @@ func configure(configFile string) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func main() { | 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() | 	flag.Parse() | ||||||
|  |  | ||||||
| 	configure(*configFile) | 	configure(*configFile) | ||||||
|  |  | ||||||
| 	router := mux.NewRouter() | 	router := mux.NewRouter() | ||||||
| 	router.HandleFunc("/avatar/{id}", requestHandler) | 	router.HandleFunc("/avatar/{id}", requestHandler) | ||||||
| 	log.Println("Starting ...") | 	log.Println(fmt.Sprintf("Starting on port %d ...", *port)) | ||||||
| 	log.Fatal(http.ListenAndServe(":8000", router)) | 	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), router)) | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user