aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-07-19 15:53:39 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-07-19 15:53:39 +0200
commit158eda06de31a52f15712fa0e5695054d15dfe3a (patch)
treefb86ecd31a1195111581f77ba49665002d442dc1 /main.go
parenta84ac778adf57d6446eef6577e617a80d4c6bb8e (diff)
downloadguichet-158eda06de31a52f15712fa0e5695054d15dfe3a.tar.gz
guichet-158eda06de31a52f15712fa0e5695054d15dfe3a.zip
Format + documentation
Diffstat (limited to 'main.go')
-rw-r--r--main.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/main.go b/main.go
index 51a23aa..c67a3dc 100644
--- a/main.go
+++ b/main.go
@@ -21,9 +21,9 @@ import (
type ConfigFile struct {
Resources []string `json:"resources"`
- HttpBindAddr string `json:"http_bind_addr"`
- LdapServerAddr string `json:"ldap_server_addr"`
- LdapTLS bool `json:"ldap_tls"`
+ HttpBindAddr string `json:"http_bind_addr"`
+ LdapServerAddr string `json:"ldap_server_addr"`
+ LdapTLS bool `json:"ldap_tls"`
BaseDN string `json:"base_dn"`
UserBaseDN string `json:"user_base_dn"`
@@ -64,7 +64,7 @@ var store sessions.Store = nil
func readConfig() ConfigFile {
// Default configuration values for certain fields
config_file := ConfigFile{
- Resources: []string{},
+ Resources: []string{},
HttpBindAddr: ":9991",
LdapServerAddr: "ldap://127.0.0.1:389",
@@ -97,17 +97,16 @@ func readConfig() ConfigFile {
// Enrich the Resource entry with default values
config_file.Resources = append(config_file.Resources, ".")
ex, err := os.Executable()
- if err == nil {
- exPath := filepath.Dir(ex)
+ if err == nil {
+ exPath := filepath.Dir(ex)
config_file.Resources = append(config_file.Resources, exPath)
- }
- fmt.Println(config_file.Resources)
+ }
return config_file
}
func selectResource(conf *ConfigFile) {
- ResourceLoop:
+ResourceLoop:
for _, p := range conf.Resources {
for _, suffix := range []string{"", "/templates", "/static"} {
_, err := os.Stat(p + suffix)
@@ -157,7 +156,7 @@ func main() {
r.HandleFunc("/admin/ldap/{dn}", handleAdminLDAP)
r.HandleFunc("/admin/create/{template}/{super_dn}", handleAdminCreate)
- staticfiles := http.FileServer(http.Dir(config.Resources[0]+"/static"))
+ staticfiles := http.FileServer(http.Dir(config.Resources[0] + "/static"))
r.Handle("/static/{file:.*}", http.StripPrefix("/static/", staticfiles))
log.Printf("Starting HTTP server on %s", config.HttpBindAddr)