diff options
| author | Shulhan <ms@kilabit.info> | 2026-02-05 06:22:10 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-02-05 06:22:10 +0700 |
| commit | 759c9b8e542d2ce159228e35c6d4138fbaef25de (patch) | |
| tree | 8f7c234bf7eb5add7e35c1c88c7ea0da6a79dbff | |
| parent | aba22ce712d13b0b99b56a860f57c9142d9440e3 (diff) | |
| download | ciigo-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.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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`) } |
