diff options
| author | Shulhan <ms@kilabit.info> | 2022-01-10 12:15:38 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-01-10 12:15:38 +0700 |
| commit | b48bc0e559cf94da8a4d270c9c28e728c5ea243b (patch) | |
| tree | a029e0d0e7b490892ad82270ccf5dd2aed5d275d | |
| parent | 55bbd8309fd7ecb1c32d692471222c2cf08fac58 (diff) | |
| download | ciigo-b48bc0e559cf94da8a4d270c9c28e728c5ea243b.tar.xz | |
go.mod: update to latest share module
| -rw-r--r-- | go.mod | 2 | ||||
| -rw-r--r-- | go.sum | 4 | ||||
| -rw-r--r-- | server.go | 35 |
3 files changed, 24 insertions, 17 deletions
@@ -4,7 +4,7 @@ go 1.16 require ( git.sr.ht/~shulhan/asciidoctor-go v0.1.1 - github.com/shuLhan/share v0.32.1-0.20211220053556-5748b1b96617 + github.com/shuLhan/share v0.33.0 ) //replace git.sr.ht/~shulhan/asciidoctor-go => ../asciidoctor-go @@ -1,8 +1,8 @@ git.sr.ht/~shulhan/asciidoctor-go v0.1.1 h1:Qxc1t07JGHvL0jHGdDTzaS4CCF9M/7ssmkGE9pONEQs= git.sr.ht/~shulhan/asciidoctor-go v0.1.1/go.mod h1:fKngGZlw91mhM+ASRjw1h9bsN4YqM9eDiwfo9uv/mrk= github.com/shuLhan/share v0.32.0/go.mod h1:1E7VQSKC7cbCmAi6izvm2S8jH5Z98a9SSS2IlvmNs/Y= -github.com/shuLhan/share v0.32.1-0.20211220053556-5748b1b96617 h1:XEBBHp5fzgr1XBJLuCb5Rw8wUmIewpvfVEI+G1wDkzg= -github.com/shuLhan/share v0.32.1-0.20211220053556-5748b1b96617/go.mod h1:6YvVpuViRgLm4e+8AIh1izGaWgV5lyuj53H19GKCZzI= +github.com/shuLhan/share v0.33.0 h1:fM/yLmAzqMECP3Gp1lFH/l4zH1UZVCvgn8BLuPI2Dnc= +github.com/shuLhan/share v0.33.0/go.mod h1:6YvVpuViRgLm4e+8AIh1izGaWgV5lyuj53H19GKCZzI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -20,7 +20,6 @@ import ( // type server struct { http *libhttp.Server - opts *libhttp.ServerOptions htmlg *htmlGenerator watcher *watcher } @@ -33,21 +32,29 @@ type server struct { // embedded HTML template. // func newServer(opts *ServeOptions) (srv *server, err error) { - logp := "newServer" + var ( + logp = "newServer" + isDevelopment = debug.Value > 0 + ) - srv = &server{ - opts: &libhttp.ServerOptions{ - Options: memfs.Options{ + if opts.Mfs == nil { + opts.Mfs = &memfs.MemFS{ + Opts: &memfs.Options{ Root: opts.Root, Excludes: defExcludes, - Development: debug.Value > 0, + Development: isDevelopment, }, - Memfs: opts.Mfs, - Address: opts.Address, - }, + } + } + + srv = &server{} + + httpdOpts := &libhttp.ServerOptions{ + Memfs: opts.Mfs, + Address: opts.Address, } - srv.http, err = libhttp.NewServer(srv.opts) + srv.http, err = libhttp.NewServer(httpdOpts) if err != nil { return nil, fmt.Errorf("%s: %w", logp, err) } @@ -65,12 +72,12 @@ func newServer(opts *ServeOptions) (srv *server, err error) { return nil, fmt.Errorf("%s: %w", logp, err) } - srv.htmlg, err = newHTMLGenerator(opts.Mfs, opts.HtmlTemplate, srv.opts.Development) + srv.htmlg, err = newHTMLGenerator(opts.Mfs, opts.HtmlTemplate, isDevelopment) if err != nil { return nil, fmt.Errorf("%s: %w", logp, err) } - if srv.opts.Development { + if isDevelopment { srv.watcher, err = newWatcher(srv.htmlg, &opts.ConvertOptions) if err != nil { return nil, fmt.Errorf("%s: %w", logp, err) @@ -88,7 +95,7 @@ func newServer(opts *ServeOptions) (srv *server, err error) { func (srv *server) start() (err error) { logp := "start" - if srv.opts.Development { + if srv.http.Options.Memfs.Opts.Development { err := srv.watcher.start() if err != nil { return fmt.Errorf("%s: %w", logp, err) @@ -96,7 +103,7 @@ func (srv *server) start() (err error) { } fmt.Printf("ciigo: starting HTTP server at %q for %q\n", - srv.opts.Address, srv.opts.Root) + srv.http.Options.Address, srv.http.Options.Memfs.Opts.Root) err = srv.http.Start() if err != nil { |
