nix-amer/internal/cnf/parser/nginx/nginx.go

37 lines
724 B
Go
Raw Normal View History

package nginx
import (
"io"
)
type nginx struct {
Lines []*Line
}
2018-11-12 11:08:54 +00:00
// NewDecoder implements parser.T
func (n *nginx) NewDecoder(r io.Reader) *decoder {
return &decoder{reader: r}
}
// Section returns the section with a given name at the root level
// nil is returned if no match found
func (l *nginx) Section(name string) *Line {
for _, elem := range l.Lines {
if elem.Type == SECTION && elem.Components[0] == name {
return elem
}
}
return nil
}
// Get returns a pointer to the assignment line the given name as key
// at the root level
func (l *nginx) Get(name string) *Line {
for _, elem := range l.Lines {
if elem.Type == ASSIGNMENT && elem.Components[0] == name {
return elem
}
}
return nil
}