diff --git a/config.go b/internal/config/public.go similarity index 78% rename from config.go rename to internal/config/public.go index 155a415..27c8d4f 100644 --- a/config.go +++ b/internal/config/public.go @@ -1,14 +1,14 @@ -package gfw +package config import ( "encoding/json" "os" ) -// LoadConfig builds a structured representation of the +// Load builds a structured representation of the // configuration file located at @path // The struct definition checks for most format errors -func LoadConfig(path string) (*controller, error) { +func Load(path string) (*Controller, error) { /* (1) Extract data ---------------------------------------------------------*/ @@ -20,7 +20,7 @@ func LoadConfig(path string) (*controller, error) { defer configFile.Close() /* (2) Init receiving dataset */ - receiver := &controller{} + receiver := &Controller{} /* (3) Decode JSON */ decoder := json.NewDecoder(configFile) @@ -30,4 +30,5 @@ func LoadConfig(path string) (*controller, error) { } return receiver, nil + } diff --git a/types.go b/internal/config/types.go similarity index 59% rename from types.go rename to internal/config/types.go index db5ce8b..7cf7bdd 100644 --- a/types.go +++ b/internal/config/types.go @@ -1,27 +1,27 @@ -package gfw +package config /* (1) Configuration ---------------------------------------------------------*/ -type methodParameter struct { +type MethodParameter struct { Description string `json:"des"` Type string `json:"typ"` Rename *string `json:"ren"` Optional *bool `json:"opt"` Default *interface{} `json:"def"` } -type method struct { +type Method struct { Description string `json:"des"` Permission [][]string `json:"per"` - Parameters *map[string]methodParameter `json:"par"` + Parameters *map[string]MethodParameter `json:"par"` Options *map[string]interface{} `json:"opt"` } -type controller struct { - GET *method `json:"GET"` - POST *method `json:"POST"` - PUT *method `json:"PUT"` - DELETE *method `json:"DELETE"` +type Controller struct { + GET *Method `json:"GET"` + POST *Method `json:"POST"` + PUT *Method `json:"PUT"` + DELETE *Method `json:"DELETE"` - Children map[string]controller `json:"/"` + Children map[string]Controller `json:"/"` }