From 82d1ccf376bb3b20d9683a1abd65c970da88a6fd Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Fri, 25 Dec 2020 19:47:27 +0800 Subject: [PATCH] fixes #286 (#315) --- rest/server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rest/server.go b/rest/server.go index bc23ce6c..82f1fdf6 100644 --- a/rest/server.go +++ b/rest/server.go @@ -1,7 +1,6 @@ package rest import ( - "errors" "log" "net/http" @@ -24,6 +23,9 @@ type ( } ) +// MustNewServer returns a server with given config of c and options defined in opts. +// Be aware that later RunOption might overwrite previous one that write the same option. +// The process will exit if error occurs. func MustNewServer(c RestConf, opts ...RunOption) *Server { engine, err := NewServer(c, opts...) if err != nil { @@ -33,11 +35,9 @@ func MustNewServer(c RestConf, opts ...RunOption) *Server { return engine } +// NewServer returns a server with given config of c and options defined in opts. +// Be aware that later RunOption might overwrite previous one that write the same option. func NewServer(c RestConf, opts ...RunOption) (*Server, error) { - if len(opts) > 1 { - return nil, errors.New("only one RunOption is allowed") - } - if err := c.SetUp(); err != nil { return nil, err }