diff options
| author | Shulhan <ms@kilabit.info> | 2021-04-03 04:05:01 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-04-03 04:40:27 +0700 |
| commit | 2c1ec60015ed4a29134be4d8ddd1c71d38bf52fa (patch) | |
| tree | 37f30fa6cbe8f3287597808153aa78500b928e7d /cmd | |
| parent | 298eb4dff25b4e97b66d49f005c896a88b0df5c6 (diff) | |
| download | ciigo-2c1ec60015ed4a29134be4d8ddd1c71d38bf52fa.tar.xz | |
all: change the Serve signature to ServeOptions
Previously, we pass four parameters to Serve function: the instance
to memfs.MemFS, the root directory, the address to listen, and
path to HTML template.
In case we need to add new parameter in the future, the Serve function
signature will changes and this is not good for consumer of API.
This commit changes the Serve function parameters to ServeOptions
so we can add optional parameter in the future without changes to its
signature.
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/ciigo-example/main.go | 11 | ||||
| -rw-r--r-- | cmd/ciigo/main.go | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/cmd/ciigo-example/main.go b/cmd/ciigo-example/main.go index 3ad8a93..3975a75 100644 --- a/cmd/ciigo-example/main.go +++ b/cmd/ciigo-example/main.go @@ -19,7 +19,16 @@ import ( var ciigoFS *memfs.MemFS func main() { - err := ciigo.Serve(ciigoFS, "_example", ":8080", "_example/html.tmpl") + opts := &ciigo.ServeOptions{ + ConvertOptions: ciigo.ConvertOptions{ + Root: "_example", + HtmlTemplate: "_example/html.tmpl", + }, + Mfs: ciigoFS, + Address: ":8080", + } + + err := ciigo.Serve(opts) if err != nil { log.Fatal(err) } diff --git a/cmd/ciigo/main.go b/cmd/ciigo/main.go index f0c2e65..07f6164 100644 --- a/cmd/ciigo/main.go +++ b/cmd/ciigo/main.go @@ -92,7 +92,14 @@ func main() { case "serve": debug.Value = 1 - err = ciigo.Serve(nil, dir, *address, *htmlTemplate) + opts := ciigo.ServeOptions{ + ConvertOptions: ciigo.ConvertOptions{ + Root: dir, + HtmlTemplate: *htmlTemplate, + }, + Address: *address, + } + err = ciigo.Serve(&opts) default: usage() |
