aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-05 06:22:10 +0700
committerShulhan <ms@kilabit.info>2026-02-05 06:22:10 +0700
commit759c9b8e542d2ce159228e35c6d4138fbaef25de (patch)
tree8f7c234bf7eb5add7e35c1c88c7ea0da6a79dbff
parentaba22ce712d13b0b99b56a860f57c9142d9440e3 (diff)
downloadciigo-759c9b8e542d2ce159228e35c6d4138fbaef25de.tar.xz
server: enable ServerOptions HandleFS by default
This allow request for .adoc/.md get redirected to .html in production environment, as we have in https://golang-id.org/proposal/ .
-rw-r--r--server.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/server.go b/server.go
index 483b7d1..702cb97 100644
--- a/server.go
+++ b/server.go
@@ -55,9 +55,7 @@ func (ciigo *Ciigo) InitHTTPServer(opts ServeOptions) (err error) {
Memfs: opts.Mfs,
Address: opts.Address,
EnableIndexHTML: opts.EnableIndexHTML,
- }
- if opts.IsDevelopment {
- httpdOpts.HandleFS = ciigo.onGet
+ HandleFS: ciigo.onGet,
}
ciigo.HTTPServer, err = libhttp.NewServer(httpdOpts)
@@ -196,7 +194,7 @@ func (ciigo *Ciigo) onGet(
http.Redirect(w, req, file, http.StatusSeeOther)
return nil, http.StatusSeeOther
}
- } else {
+ } else if ciigo.serveOpts.IsDevelopment {
if node.IsDir() {
file = path.Join(node.Path, `index.html`)
} else {
@@ -207,6 +205,10 @@ func (ciigo *Ciigo) onGet(
}
}
}
+ if !ciigo.serveOpts.IsDevelopment {
+ return node, 0
+ }
+
if file[len(file)-1] == '/' {
file = path.Join(file, `index.html`)
}