diff --git a/config/datatype/builtin/any.go b/datatype/builtin/any.go similarity index 87% rename from config/datatype/builtin/any.go rename to datatype/builtin/any.go index 5e3cc94..c7af7e9 100644 --- a/config/datatype/builtin/any.go +++ b/datatype/builtin/any.go @@ -1,6 +1,6 @@ package builtin -import "git.xdrm.io/go/aicra/config/datatype" +import "git.xdrm.io/go/aicra/datatype" // AnyDataType is what its name tells type AnyDataType struct{} diff --git a/config/datatype/builtin/any_test.go b/datatype/builtin/any_test.go similarity index 95% rename from config/datatype/builtin/any_test.go rename to datatype/builtin/any_test.go index 4c3678e..c06b3cf 100644 --- a/config/datatype/builtin/any_test.go +++ b/datatype/builtin/any_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestAny_AvailableTypes(t *testing.T) { diff --git a/config/datatype/builtin/bool.go b/datatype/builtin/bool.go similarity index 93% rename from config/datatype/builtin/bool.go rename to datatype/builtin/bool.go index a57721d..2b0240b 100644 --- a/config/datatype/builtin/bool.go +++ b/datatype/builtin/bool.go @@ -1,6 +1,6 @@ package builtin -import "git.xdrm.io/go/aicra/config/datatype" +import "git.xdrm.io/go/aicra/datatype" // BoolDataType is what its name tells type BoolDataType struct{} diff --git a/config/datatype/builtin/bool_test.go b/datatype/builtin/bool_test.go similarity index 97% rename from config/datatype/builtin/bool_test.go rename to datatype/builtin/bool_test.go index 52ef4c2..e7051c4 100644 --- a/config/datatype/builtin/bool_test.go +++ b/datatype/builtin/bool_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestBool_AvailableTypes(t *testing.T) { diff --git a/config/datatype/builtin/float.go b/datatype/builtin/float.go similarity index 95% rename from config/datatype/builtin/float.go rename to datatype/builtin/float.go index 1e2fd18..6f64e58 100644 --- a/config/datatype/builtin/float.go +++ b/datatype/builtin/float.go @@ -3,7 +3,7 @@ package builtin import ( "encoding/json" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) // FloatDataType is what its name tells diff --git a/config/datatype/builtin/float_test.go b/datatype/builtin/float_test.go similarity index 97% rename from config/datatype/builtin/float_test.go rename to datatype/builtin/float_test.go index f862521..4d692b6 100644 --- a/config/datatype/builtin/float_test.go +++ b/datatype/builtin/float_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestFloat64_AvailableTypes(t *testing.T) { diff --git a/config/datatype/builtin/int.go b/datatype/builtin/int.go similarity index 96% rename from config/datatype/builtin/int.go rename to datatype/builtin/int.go index a82e2ad..453c4f1 100644 --- a/config/datatype/builtin/int.go +++ b/datatype/builtin/int.go @@ -4,7 +4,7 @@ import ( "encoding/json" "math" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) // IntDataType is what its name tells diff --git a/config/datatype/builtin/int_test.go b/datatype/builtin/int_test.go similarity index 97% rename from config/datatype/builtin/int_test.go rename to datatype/builtin/int_test.go index c3126f3..01837cc 100644 --- a/config/datatype/builtin/int_test.go +++ b/datatype/builtin/int_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestInt_AvailableTypes(t *testing.T) { diff --git a/config/datatype/builtin/string.go b/datatype/builtin/string.go similarity index 98% rename from config/datatype/builtin/string.go rename to datatype/builtin/string.go index 95d1fff..afee83a 100644 --- a/config/datatype/builtin/string.go +++ b/datatype/builtin/string.go @@ -4,7 +4,7 @@ import ( "regexp" "strconv" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) var fixedLengthRegex = regexp.MustCompile(`^string\((\d+)\)$`) diff --git a/config/datatype/builtin/string_test.go b/datatype/builtin/string_test.go similarity index 98% rename from config/datatype/builtin/string_test.go rename to datatype/builtin/string_test.go index e332ea3..cb51216 100644 --- a/config/datatype/builtin/string_test.go +++ b/datatype/builtin/string_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestString_AvailableTypes(t *testing.T) { diff --git a/config/datatype/builtin/uint.go b/datatype/builtin/uint.go similarity index 96% rename from config/datatype/builtin/uint.go rename to datatype/builtin/uint.go index ab02728..3f5bd76 100644 --- a/config/datatype/builtin/uint.go +++ b/datatype/builtin/uint.go @@ -4,7 +4,7 @@ import ( "encoding/json" "math" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) // UintDataType is what its name tells diff --git a/config/datatype/builtin/uint_test.go b/datatype/builtin/uint_test.go similarity index 97% rename from config/datatype/builtin/uint_test.go rename to datatype/builtin/uint_test.go index ae4ef03..55686cc 100644 --- a/config/datatype/builtin/uint_test.go +++ b/datatype/builtin/uint_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestUint_AvailableTypes(t *testing.T) { diff --git a/config/datatype/types.go b/datatype/types.go similarity index 69% rename from config/datatype/types.go rename to datatype/types.go index 9bcefbb..ad4be63 100644 --- a/config/datatype/types.go +++ b/datatype/types.go @@ -4,9 +4,9 @@ package datatype // and casts the value into a compatible type type Validator func(value interface{}) (cast interface{}, valid bool) -// DataType builds a DataType from the type definition (from the +// T builds a T from the type definition (from the // configuration field "type") and returns NIL if the type -// definition does not match this DataType -type DataType interface { +// definition does not match this T +type T interface { Build(typeDefinition string) Validator } diff --git a/config/config_test.go b/internal/config/config_test.go similarity index 99% rename from config/config_test.go rename to internal/config/config_test.go index b45e15a..c68b316 100644 --- a/config/config_test.go +++ b/internal/config/config_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "git.xdrm.io/go/aicra/config/datatype/builtin" + "git.xdrm.io/go/aicra/datatype/builtin" ) func TestLegalServiceName(t *testing.T) { diff --git a/config/errors.go b/internal/config/errors.go similarity index 100% rename from config/errors.go rename to internal/config/errors.go diff --git a/config/func.go b/internal/config/func.go similarity index 100% rename from config/func.go rename to internal/config/func.go diff --git a/config/parameter.go b/internal/config/parameter.go similarity index 83% rename from config/parameter.go rename to internal/config/parameter.go index 7537d01..af08e49 100644 --- a/config/parameter.go +++ b/internal/config/parameter.go @@ -1,6 +1,6 @@ package config -import "git.xdrm.io/go/aicra/config/datatype" +import "git.xdrm.io/go/aicra/datatype" func (param *Parameter) checkAndFormat() error { @@ -24,7 +24,7 @@ func (param *Parameter) checkAndFormat() error { } // assigns the first matching data type from the type definition -func (param *Parameter) assignDataType(types []datatype.DataType) bool { +func (param *Parameter) assignDataType(types []datatype.T) bool { for _, dtype := range types { param.Validator = dtype.Build(param.Type) if param.Validator != nil { diff --git a/config/server.go b/internal/config/server.go similarity index 96% rename from config/server.go rename to internal/config/server.go index 5a21a09..96f3cbd 100644 --- a/config/server.go +++ b/internal/config/server.go @@ -7,14 +7,14 @@ import ( "net/http" "strings" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) // Parse builds a server configuration from a json reader and checks for most format errors. // you can provide additional DataTypes as variadic arguments -func Parse(r io.Reader, dtypes ...datatype.DataType) (*Server, error) { +func Parse(r io.Reader, dtypes ...datatype.T) (*Server, error) { server := &Server{ - Types: make([]datatype.DataType, 0), + Types: make([]datatype.T, 0), Services: make([]*Service, 0), } // add data types diff --git a/config/service.go b/internal/config/service.go similarity index 97% rename from config/service.go rename to internal/config/service.go index 81018a1..4edc764 100644 --- a/config/service.go +++ b/internal/config/service.go @@ -6,7 +6,7 @@ import ( "regexp" "strings" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) var braceRegex = regexp.MustCompile(`^{([a-z_-]+)}$`) @@ -86,7 +86,7 @@ func (svc *Service) checkPattern() error { return nil } -func (svc *Service) checkAndFormatInput(types []datatype.DataType) error { +func (svc *Service) checkAndFormatInput(types []datatype.T) error { // ignore no parameter if svc.Input == nil || len(svc.Input) < 1 { diff --git a/config/types.go b/internal/config/types.go similarity index 94% rename from config/types.go rename to internal/config/types.go index 6408742..9e2c9bf 100644 --- a/config/types.go +++ b/internal/config/types.go @@ -3,14 +3,14 @@ package config import ( "net/http" - "git.xdrm.io/go/aicra/config/datatype" + "git.xdrm.io/go/aicra/datatype" ) var availableHTTPMethods = []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete} // Server represents a full server configuration type Server struct { - Types []datatype.DataType + Types []datatype.T Services []*Service }