This commit is contained in:
		| @@ -20,3 +20,5 @@ Le fichier de configuration est passé dans Configure et doit être au format js | |||||||
| ``` | ``` | ||||||
|  |  | ||||||
| Le MainTemplate est utilisé pour charger tous les templates, il peut être utilisé tel quel ou modifié si vous savez ce que fous faites. Dans le doute, laissez celui par défaut. | Le MainTemplate est utilisé pour charger tous les templates, il peut être utilisé tel quel ou modifié si vous savez ce que fous faites. Dans le doute, laissez celui par défaut. | ||||||
|  |  | ||||||
|  | On lance enfin le serveur en utilisant Start() | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
| * @Author: Bartuccio Antoine | * @Author: Bartuccio Antoine | ||||||
| * @Date:   2018-07-14 11:32:11 | * @Date:   2018-07-14 11:32:11 | ||||||
| * @Last Modified by:   klmp200 | * @Last Modified by:   klmp200 | ||||||
| * @Last Modified time: 2018-07-14 12:58:10 | * @Last Modified time: 2018-07-14 13:01:20 | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| package gowebframework | package gowebframework | ||||||
| @@ -34,11 +34,17 @@ type Config struct { | |||||||
|  |  | ||||||
| var ServerConfig Config | var ServerConfig Config | ||||||
|  |  | ||||||
|  | // Load templates and configuration | ||||||
| func Configure(config_file_name string, custom_config_file_name string) { | func Configure(config_file_name string, custom_config_file_name string) { | ||||||
| 	loadConfiguration(config_file_name, custom_config_file_name) | 	loadConfiguration(config_file_name, custom_config_file_name) | ||||||
| 	loadTemplates() | 	loadTemplates() | ||||||
| 	// Launch statics server | } | ||||||
|  |  | ||||||
|  | // Starts server | ||||||
|  | func Start() { | ||||||
| 	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(ServerConfig.StaticFolderPath)))) | 	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(ServerConfig.StaticFolderPath)))) | ||||||
|  | 	log.Println("Server listening on http://localhost" + ServerConfig.ServerPort) | ||||||
|  | 	log.Fatal(http.ListenAndServe(ServerConfig.ServerPort, nil)) | ||||||
| } | } | ||||||
|  |  | ||||||
| func loadConfiguration(config_file_name string, custom_config_file_name string) { | func loadConfiguration(config_file_name string, custom_config_file_name string) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user