Handle server startup
the build was successful Details

This commit is contained in:
Antoine Bartuccio 2018-07-14 13:02:12 +02:00
parent 50c4f8e6d9
commit 0823d4a2b8
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 10 additions and 2 deletions

View File

@ -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.
On lance enfin le serveur en utilisant Start()

View File

@ -2,7 +2,7 @@
* @Author: Bartuccio Antoine
* @Date: 2018-07-14 11:32:11
* @Last Modified by: klmp200
* @Last Modified time: 2018-07-14 12:58:10
* @Last Modified time: 2018-07-14 13:01:20
*/
package gowebframework
@ -34,11 +34,17 @@ type Config struct {
var ServerConfig Config
// Load templates and configuration
func Configure(config_file_name string, custom_config_file_name string) {
loadConfiguration(config_file_name, custom_config_file_name)
loadTemplates()
// Launch statics server
}
// Starts server
func Start() {
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) {