forked from tufanbarisyildirim/gonginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
47 lines (39 loc) · 1016 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gonginx
import (
"errors"
)
// Server represents server block
type Server struct {
Block IBlock
Comment []string
}
// SetComment set comment of server directive
func (s *Server) SetComment(comment []string) {
s.Comment = comment
}
// GetComment get comment of server directive
func (s *Server) GetComment() []string {
return s.Comment
}
// NewServer create a server block from a directive with block
func NewServer(directive IDirective) (*Server, error) {
if block := directive.GetBlock(); block != nil {
return &Server{
Block: block,
Comment: directive.GetComment(),
}, nil
}
return nil, errors.New("server directive must have a block")
}
// GetName get directive name to construct the statment string
func (s *Server) GetName() string { //the directive name.
return "server"
}
// GetParameters get directive parameters if any
func (s *Server) GetParameters() []string {
return []string{}
}
// GetBlock get block if any
func (s *Server) GetBlock() IBlock {
return s.Block
}