Compare commits
	
		
			2 commits
		
	
	
		
			
				2a37725b2e
			
			...
			
				ff92e30232
			
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							
							
								
							
							
	
	
		
			
		
	
	ff92e30232 | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	b62a807f89 | 
						
						
							
					 3 changed files with 18 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -34,6 +34,8 @@ The file format is **JSON**:
 | 
			
		|||
* **languages** ([]string): List of supported [languages](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)
 | 
			
		||||
* **language** (string): Default language (default "text")
 | 
			
		||||
* **enable_upload_file_button** (bool): Display the upload file button in the UI (default true)
 | 
			
		||||
* **tls_cert_file** (string): Path to TLS certificate file to enable HTTPS
 | 
			
		||||
* **tls_key_file** (string): Path to TLS key file to enable HTTPS
 | 
			
		||||
* **bootstrap_directory** (string): Serve [Bootstrap](https://getbootstrap.com/) assets from this local directory (ex: "./node_modules/bootstrap/dist"). See **Dependencies** for details.
 | 
			
		||||
 | 
			
		||||
The configuration file is not required but the service might not be exposed to the public.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,8 @@ type Config struct {
 | 
			
		|||
	Languages              []string `json:"languages"`
 | 
			
		||||
	Language               string   `json:"language"`
 | 
			
		||||
	EnableUploadFileButton bool     `json:"enable_upload_file_button"`
 | 
			
		||||
	TLSCertFile            string   `json:"tls_cert_file"`
 | 
			
		||||
	TLSKeyFile             string   `json:"tls_key_file"`
 | 
			
		||||
	BootstrapDirectory     string   `json:"bootstrap_directory"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -95,3 +97,7 @@ func (c *Config) Check() error {
 | 
			
		|||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) HasTLS() bool {
 | 
			
		||||
	return c.TLSCertFile != "" && c.TLSKeyFile != ""
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,9 +13,10 @@ import (
 | 
			
		|||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"git.riou.xyz/jriou/coller/internal"
 | 
			
		||||
	"github.com/gorilla/mux"
 | 
			
		||||
	"github.com/prometheus/client_golang/prometheus/promhttp"
 | 
			
		||||
 | 
			
		||||
	"git.riou.xyz/jriou/coller/internal"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var passwordLength = internal.MIN_PASSWORD_LENGTH
 | 
			
		||||
| 
						 | 
				
			
			@ -478,6 +479,12 @@ func (s *Server) Start() error {
 | 
			
		|||
	r.Path("/").Handler(&HomeHandler{Templates: templates, PageData: p}).Methods("GET")
 | 
			
		||||
 | 
			
		||||
	addr := fmt.Sprintf("%s:%d", s.config.ListenAddress, s.config.ListenPort)
 | 
			
		||||
	s.logger.Info(fmt.Sprintf("listening to %s:%d", s.config.ListenAddress, s.config.ListenPort))
 | 
			
		||||
 | 
			
		||||
	if s.config.HasTLS() {
 | 
			
		||||
		s.logger.Info(fmt.Sprintf("listening to %s:%d (https)", s.config.ListenAddress, s.config.ListenPort))
 | 
			
		||||
		return http.ListenAndServeTLS(addr, s.config.TLSCertFile, s.config.TLSKeyFile, r)
 | 
			
		||||
	} else {
 | 
			
		||||
		s.logger.Info(fmt.Sprintf("listening to %s:%d (http)", s.config.ListenAddress, s.config.ListenPort))
 | 
			
		||||
		return http.ListenAndServe(addr, r)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue