Big ol' gofmt.
This commit is contained in:
parent
56d8dde14a
commit
5258b29c6b
|
@ -2,11 +2,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -93,7 +93,7 @@ func getConfig(filename string) (Config, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Absolutise DocBase
|
// Absolutise DocBase
|
||||||
if(!filepath.IsAbs(config.DocBase)) {
|
if !filepath.IsAbs(config.DocBase) {
|
||||||
abs, err := filepath.Abs(config.DocBase)
|
abs, err := filepath.Abs(config.DocBase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, err
|
return config, err
|
||||||
|
@ -103,7 +103,7 @@ func getConfig(filename string) (Config, error) {
|
||||||
|
|
||||||
// Absolutise CGI paths
|
// Absolutise CGI paths
|
||||||
for index, cgiPath := range config.CGIPaths {
|
for index, cgiPath := range config.CGIPaths {
|
||||||
if(!filepath.IsAbs(cgiPath)) {
|
if !filepath.IsAbs(cgiPath) {
|
||||||
config.CGIPaths[index] = filepath.Join(config.DocBase, cgiPath)
|
config.CGIPaths[index] = filepath.Join(config.DocBase, cgiPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func getConfig(filename string) (Config, error) {
|
||||||
|
|
||||||
// Absolutise SCGI paths
|
// Absolutise SCGI paths
|
||||||
for index, scgiPath := range config.SCGIPaths {
|
for index, scgiPath := range config.SCGIPaths {
|
||||||
if(!filepath.IsAbs(scgiPath)) {
|
if !filepath.IsAbs(scgiPath) {
|
||||||
config.SCGIPaths[index] = filepath.Join(config.DocBase, scgiPath)
|
config.SCGIPaths[index] = filepath.Join(config.DocBase, scgiPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func generateDirectoryListing(URL *url.URL, path string, config Config) (string,
|
||||||
return false // Should not happen
|
return false // Should not happen
|
||||||
})
|
})
|
||||||
// Sort directories before file
|
// Sort directories before file
|
||||||
if(config.DirectorySubdirsFirst) {
|
if config.DirectorySubdirsFirst {
|
||||||
sort.SliceStable(files, func(i, j int) bool {
|
sort.SliceStable(files, func(i, j int) bool {
|
||||||
// If i is a dir and j is a file, i < j
|
// If i is a dir and j is a file, i < j
|
||||||
if files[i].IsDir() && !files[j].IsDir() {
|
if files[i].IsDir() && !files[j].IsDir() {
|
||||||
|
|
|
@ -262,11 +262,11 @@ func serveFile(path string, log *LogEntry, conn net.Conn, config Config, errorLo
|
||||||
mimeType = "application/octet-stream"
|
mimeType = "application/octet-stream"
|
||||||
}
|
}
|
||||||
// Add charset parameter
|
// Add charset parameter
|
||||||
if strings.HasPrefix(mimeType,"text/gemini") && config.DefaultEncoding != "" {
|
if strings.HasPrefix(mimeType, "text/gemini") && config.DefaultEncoding != "" {
|
||||||
mimeType += "; charset=" + config.DefaultEncoding
|
mimeType += "; charset=" + config.DefaultEncoding
|
||||||
}
|
}
|
||||||
// Add lang parameter
|
// Add lang parameter
|
||||||
if strings.HasPrefix(mimeType,"text/gemini") && config.DefaultLang != "" {
|
if strings.HasPrefix(mimeType, "text/gemini") && config.DefaultLang != "" {
|
||||||
mimeType += "; lang=" + config.DefaultLang
|
mimeType += "; lang=" + config.DefaultLang
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -52,7 +52,7 @@ func main() {
|
||||||
}
|
}
|
||||||
defer errorLogFile.Close()
|
defer errorLogFile.Close()
|
||||||
}
|
}
|
||||||
errorLog := log.New(errorLogFile, "", log.Ldate | log.Ltime)
|
errorLog := log.New(errorLogFile, "", log.Ldate|log.Ltime)
|
||||||
|
|
||||||
var accessLogFile *os.File
|
var accessLogFile *os.File
|
||||||
// TODO: Find a more elegant/portable way to disable logging
|
// TODO: Find a more elegant/portable way to disable logging
|
||||||
|
|
Loading…
Reference in New Issue