From c9326a1bb3c0badd66982a7e54c9ec2e17749e2b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 20 May 2018 10:46:39 +0200 Subject: [PATCH] moved 'config' in /internal --- config.go => internal/config/public.go | 9 +++++---- types.go => internal/config/types.go | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) rename config.go => internal/config/public.go (78%) rename types.go => internal/config/types.go (59%) 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:"/"` }