mirror of
https://github.com/bluenviron/mediamtx
synced 2024-12-15 11:14:43 +00:00
42 lines
761 B
Go
42 lines
761 B
Go
package conf
|
|
|
|
import (
|
|
"encoding/json"
|
|
"reflect"
|
|
)
|
|
|
|
var globalValuesType = func() reflect.Type {
|
|
var fields []reflect.StructField
|
|
rt := reflect.TypeOf(Conf{})
|
|
nf := rt.NumField()
|
|
|
|
for i := 0; i < nf; i++ {
|
|
f := rt.Field(i)
|
|
j := f.Tag.Get("json")
|
|
|
|
if j != "-" && j != "pathDefaults" && j != "paths" {
|
|
fields = append(fields, reflect.StructField{
|
|
Name: f.Name,
|
|
Type: f.Type,
|
|
Tag: f.Tag,
|
|
})
|
|
}
|
|
}
|
|
|
|
return reflect.StructOf(fields)
|
|
}()
|
|
|
|
func newGlobalValues() interface{} {
|
|
return reflect.New(globalValuesType).Interface()
|
|
}
|
|
|
|
// Global is the global part of Conf.
|
|
type Global struct {
|
|
Values interface{}
|
|
}
|
|
|
|
// MarshalJSON implements json.Marshaler.
|
|
func (p *Global) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(p.Values)
|
|
}
|