37 lines
724 B
Go
37 lines
724 B
Go
package nginx
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
type nginx struct {
|
|
Lines []*Line
|
|
}
|
|
|
|
// 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
|
|
}
|