moved 'config' in /internal

This commit is contained in:
Adrien Marquès 2018-05-20 10:46:39 +02:00
parent 7f8910f793
commit c9326a1bb3
2 changed files with 15 additions and 14 deletions

View File

@ -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
}

View File

@ -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:"/"`
}