diff options
| author | Shulhan <ms@kilabit.info> | 2024-03-15 13:49:49 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-03-15 13:49:49 +0700 |
| commit | 0a20cfd1fe3e5e359edb75b0f4d44e4ce5a12554 (patch) | |
| tree | 39c7c66ebacd3947136f88a31b2ed5e2be190b9c /server.go | |
| parent | b947c36942369177bb6f6afc02e1d76b333c2d70 (diff) | |
| download | ciigo-0a20cfd1fe3e5e359edb75b0f4d44e4ce5a12554.tar.xz | |
go.mod: update module "pakakeh.go" to tip
Diffstat (limited to 'server.go')
| -rw-r--r-- | server.go | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -28,15 +28,7 @@ type server struct { // The htmlTemplate parameter is optional, if not set its default to // embedded HTML template. func newServer(opts *ServeOptions) (srv *server, err error) { - var ( - logp = `newServer` - - tmplNode *memfs.Node - httpdOpts *libhttp.ServerOptions - epInSearch *libhttp.Endpoint - - pathHTMLTemplate string - ) + var logp = `newServer` if opts.Mfs == nil { opts.Mfs = &memfs.MemFS{ @@ -54,7 +46,7 @@ func newServer(opts *ServeOptions) (srv *server, err error) { opts: *opts, } - httpdOpts = &libhttp.ServerOptions{ + var httpdOpts = libhttp.ServerOptions{ Memfs: opts.Mfs, Address: opts.Address, } @@ -64,7 +56,7 @@ func newServer(opts *ServeOptions) (srv *server, err error) { return nil, fmt.Errorf(`%s: %w`, logp, err) } - epInSearch = &libhttp.Endpoint{ + var epInSearch = libhttp.Endpoint{ Method: libhttp.RequestMethodGet, Path: `/_internal/search`, RequestType: libhttp.RequestTypeQuery, @@ -77,6 +69,8 @@ func newServer(opts *ServeOptions) (srv *server, err error) { return nil, fmt.Errorf(`%s: %w`, logp, err) } + var pathHTMLTemplate string + if opts.IsDevelopment { pathHTMLTemplate = opts.HTMLTemplate } @@ -87,6 +81,8 @@ func newServer(opts *ServeOptions) (srv *server, err error) { } if !opts.IsDevelopment { + var tmplNode *memfs.Node + tmplNode, _ = opts.Mfs.Get(internalTemplatePath) if tmplNode != nil { srv.converter.tmpl, err = srv.converter.tmpl.Parse(string(tmplNode.Content)) |
