mirror of
https://code.rocketnine.space/tslocum/twins.git
synced 2024-11-27 11:38:14 +01:00
Add configuration option Lang
This commit is contained in:
parent
f91f42464d
commit
19b89bfd9e
3 changed files with 23 additions and 4 deletions
|
@ -133,6 +133,10 @@ Request sensitive text input from the user. Text will not be shown as it is ente
|
|||
When enabled, directories without an index file will serve a list of their
|
||||
contents. This attribute is disabled by default.
|
||||
|
||||
##### Lang
|
||||
|
||||
Specifies content language. This is sent to clients via the MIME type `lang` parameter.
|
||||
|
||||
##### Log
|
||||
|
||||
Path to log file. Requests are logged in [Apache format](https://httpd.apache.org/docs/2.2/logs.html#combined),
|
||||
|
@ -199,6 +203,7 @@ hosts:
|
|||
default: # Default host configuration
|
||||
paths: # Default path attributes
|
||||
-
|
||||
lang: en
|
||||
log: /srv/log/gemini.log
|
||||
symlinks: true # Follow symbolic links
|
||||
gemini.rocks:
|
||||
|
|
|
@ -50,6 +50,9 @@ type pathConfig struct {
|
|||
// FastCGI server address
|
||||
FastCGI string
|
||||
|
||||
// Language
|
||||
Lang string
|
||||
|
||||
// Log file
|
||||
Log string
|
||||
|
||||
|
@ -188,6 +191,9 @@ func readconfig(configPath string) error {
|
|||
if defaultPath.FastCGI != "" && serve.FastCGI == "" {
|
||||
serve.FastCGI = defaultPath.FastCGI
|
||||
}
|
||||
if defaultPath.Lang != "" && serve.Lang == "" {
|
||||
serve.Lang = defaultPath.Lang
|
||||
}
|
||||
if defaultPath.Log != "" && serve.Log == "" {
|
||||
serve.Log = defaultPath.Log
|
||||
}
|
||||
|
|
16
server.go
16
server.go
|
@ -82,19 +82,27 @@ func writeStatus(c net.Conn, code int) int {
|
|||
}
|
||||
|
||||
func writeSuccess(c net.Conn, serve *pathConfig, contentType string, size int64) int {
|
||||
// Content type
|
||||
meta := contentType
|
||||
if serve.Type != "" {
|
||||
meta = serve.Type
|
||||
}
|
||||
|
||||
if !config.DisableSize && size >= 0 {
|
||||
meta += fmt.Sprintf("; size=%d", size)
|
||||
}
|
||||
|
||||
// Cache
|
||||
if serve.cache != cacheUnset {
|
||||
meta += fmt.Sprintf("; cache=%d", serve.cache)
|
||||
}
|
||||
|
||||
// Language
|
||||
if serve.Lang != "" {
|
||||
meta += fmt.Sprintf("; lang=%s", serve.Lang)
|
||||
}
|
||||
|
||||
// Size
|
||||
if !config.DisableSize && size >= 0 {
|
||||
meta += fmt.Sprintf("; size=%d", size)
|
||||
}
|
||||
|
||||
writeHeader(c, statusSuccess, meta)
|
||||
return statusSuccess
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue