aboutsummaryrefslogtreecommitdiff
path: root/cmd/ciigo-example
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-04-03 04:05:01 +0700
committerShulhan <ms@kilabit.info>2021-04-03 04:40:27 +0700
commit2c1ec60015ed4a29134be4d8ddd1c71d38bf52fa (patch)
tree37f30fa6cbe8f3287597808153aa78500b928e7d /cmd/ciigo-example
parent298eb4dff25b4e97b66d49f005c896a88b0df5c6 (diff)
downloadciigo-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/ciigo-example')
-rw-r--r--cmd/ciigo-example/main.go11
1 files changed, 10 insertions, 1 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)
}