mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
parent
bb6d49c17e
commit
82d1ccf376
@ -1,7 +1,6 @@
|
|||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"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 {
|
func MustNewServer(c RestConf, opts ...RunOption) *Server {
|
||||||
engine, err := NewServer(c, opts...)
|
engine, err := NewServer(c, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -33,11 +35,9 @@ func MustNewServer(c RestConf, opts ...RunOption) *Server {
|
|||||||
return engine
|
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) {
|
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 {
|
if err := c.SetUp(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user