diff --git a/driver/generic.go b/driver/generic.go index ec0c078..0e3de04 100644 --- a/driver/generic.go +++ b/driver/generic.go @@ -64,7 +64,7 @@ func (d *Generic) Load(_path []string, _method string) (func(response.Arguments) if outErr, ok := output["error"]; ok { errCode, ok := outErr.(float64) if ok { - res.Err = e.Error{int(errCode), "unknown reason", nil} + res.Err = e.Error{Code: int(errCode), Reason: "unknown reason", Arguments: nil} } delete(output, "error") diff --git a/driver/types.go b/driver/types.go index 17516aa..2645d89 100644 --- a/driver/types.go +++ b/driver/types.go @@ -5,6 +5,7 @@ import ( "git.xdrm.io/go/aicra/response" ) +// Driver defines the driver interface to load controller/middleware implementation or executables type Driver interface { Load(_path []string, _method string) (func(response.Arguments) response.Response, err.Error) } diff --git a/internal/apirequest/dataset.go b/internal/request/dataset.go similarity index 99% rename from internal/apirequest/dataset.go rename to internal/request/dataset.go index 25468c5..114b089 100644 --- a/internal/apirequest/dataset.go +++ b/internal/request/dataset.go @@ -1,4 +1,4 @@ -package apirequest +package request import ( "encoding/json" diff --git a/internal/apirequest/parameter.go b/internal/request/parameter.go similarity index 92% rename from internal/apirequest/parameter.go rename to internal/request/parameter.go index e5e4398..0d21d83 100644 --- a/internal/apirequest/parameter.go +++ b/internal/request/parameter.go @@ -1,4 +1,4 @@ -package apirequest +package request // Parse parameter (json-like) if not already done func (i *Parameter) Parse() { diff --git a/internal/apirequest/request.go b/internal/request/request.go similarity index 99% rename from internal/apirequest/request.go rename to internal/request/request.go index e06adf8..9dde061 100644 --- a/internal/apirequest/request.go +++ b/internal/request/request.go @@ -1,4 +1,4 @@ -package apirequest +package request import ( "encoding/json" diff --git a/internal/apirequest/types.go b/internal/request/types.go similarity index 98% rename from internal/apirequest/types.go rename to internal/request/types.go index 6d6e1f8..4b38c4b 100644 --- a/internal/apirequest/types.go +++ b/internal/request/types.go @@ -1,4 +1,4 @@ -package apirequest +package request // Request represents a request by its URI, controller path and data (uri, get, post) type Request struct { diff --git a/internal/apirequest/utils.go b/internal/request/utils.go similarity index 99% rename from internal/apirequest/utils.go rename to internal/request/utils.go index 56be8e5..6af5abb 100644 --- a/internal/apirequest/utils.go +++ b/internal/request/utils.go @@ -1,4 +1,4 @@ -package apirequest +package request import ( "encoding/json" diff --git a/server.go b/server.go index 552889b..add1fae 100644 --- a/server.go +++ b/server.go @@ -4,9 +4,9 @@ import ( "errors" "git.xdrm.io/go/aicra/driver" e "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/internal/apirequest" "git.xdrm.io/go/aicra/internal/checker" "git.xdrm.io/go/aicra/internal/config" + apirequest "git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/middleware" "log" "net/http" @@ -23,6 +23,7 @@ type Server struct { driver driver.Driver } +// ErrNilDriver is raised when a NULL driver is given to the constructor var ErrNilDriver = errors.New("the driver is ") // New creates a framework instance from a configuration file diff --git a/util.go b/util.go index 92774d5..fdd7a82 100644 --- a/util.go +++ b/util.go @@ -3,8 +3,8 @@ package aicra import ( "encoding/json" "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/internal/apirequest" "git.xdrm.io/go/aicra/internal/config" + apirequest "git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/response" "log" "net/http"