From 759c9b8e542d2ce159228e35c6d4138fbaef25de Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 5 Feb 2026 06:22:10 +0700 Subject: 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/ . --- server.go | 10 ++++++---- 1 file 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`) } -- cgit v1.3