From 07bbdbbe30cf03d35042e21916bdb73257c4ab3a Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 9 Jul 2018 00:15:29 +0200 Subject: [PATCH] rename 'implement' into 'response' --- README.md | 8 ++++---- internal/request/request.go | 6 +++--- {implement => response}/arguments.go | 2 +- {implement => response}/response.go | 2 +- {implement => response}/types.go | 2 +- server.go | 4 ++-- util.go | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) rename {implement => response}/arguments.go (87%) rename {implement => response}/response.go (95%) rename {implement => response}/types.go (91%) diff --git a/README.md b/README.md index a91fa42..d2829cc 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ In order for your project to manage authentication, the best solution is to crea Each middleware must be directly inside the `middleware` folder. -> Example - the `1-authentication` middleware will be inside `middleware/1-authentication/main.go`. +> Example - the `1-authentication` middleware will be inside `middleware/1-authentication/main.go`. **Note** - middleware execution will be ordered by name. Prefixing your middlewares with their order is a good practice. @@ -116,7 +116,7 @@ Each middleware must be directly inside the `middleware` folder. ##### 4. Custom types -In your configuration you will have to use built-in types (*e.g.* int, any, varchar), but if you want project-specific ones, you can add your own types inside the `type` folder. You can check what structure to follow by looking at the [built-in types](https://git.xdrm.io/go/aicra/src/master/checker/default). +In your configuration you will have to use built-in types (*e.g.* int, any, varchar), but if you want project-specific ones, you can add your own types inside the `type` folder. You can check what structure to follow by looking at the [built-in types](https://git.xdrm.io/go/aicra/src/master/internal/checker/default). @@ -126,7 +126,7 @@ Each type must be inside a unique package directly inside the `type` folder. The #### III. Build your project -After each controller, middleware or type edition, you'll have to rebuild the project. This can be achieved through the command-line builder. +After each controller, middleware or type edition, you'll have to rebuild the project. This can be achieved through the command-line builder. Usage is `aicra [options] /path/to/your/project`. @@ -158,7 +158,7 @@ import "git.xdrm.io/go/aicra" func main() { server, err := aicra.New("manifest.json") if err != nil { return } - + server.Listen(4242) } ``` diff --git a/internal/request/request.go b/internal/request/request.go index 824d282..c1ebfc7 100644 --- a/internal/request/request.go +++ b/internal/request/request.go @@ -3,7 +3,7 @@ package request import ( "encoding/json" "fmt" - "git.xdrm.io/go/aicra/implement" + "git.xdrm.io/go/aicra/response" "log" "net/http" "plugin" @@ -93,7 +93,7 @@ func FetchFormData(req *http.Request) map[string]interface{} { // LoadController tries to load a controller from its uri // checks for its given method ('Get', 'Post', 'Put', or 'Delete') -func (i *Request) LoadController(method string) (func(implement.Arguments, *implement.Response) implement.Response, error) { +func (i *Request) LoadController(method string) (func(response.Arguments, *response.Response) response.Response, error) { /* (1) Build controller path */ path := strings.Join(i.Path, "-") @@ -121,7 +121,7 @@ func (i *Request) LoadController(method string) (func(implement.Arguments, *impl } /* (4) Check signature */ - callable, validSignature := m.(func(implement.Arguments, *implement.Response) implement.Response) + callable, validSignature := m.(func(response.Arguments, *response.Response) response.Response) if !validSignature { return nil, fmt.Errorf("Invalid signature for method %s", method) } diff --git a/implement/arguments.go b/response/arguments.go similarity index 87% rename from implement/arguments.go rename to response/arguments.go index d8ad036..d17798a 100644 --- a/implement/arguments.go +++ b/response/arguments.go @@ -1,4 +1,4 @@ -package implement +package response // Checks whether a key exists in the arguments func (i Arguments) Has(key string) bool { diff --git a/implement/response.go b/response/response.go similarity index 95% rename from implement/response.go rename to response/response.go index 53b6341..7daf561 100644 --- a/implement/response.go +++ b/response/response.go @@ -1,4 +1,4 @@ -package implement +package response import ( "git.xdrm.io/go/aicra/err" diff --git a/implement/types.go b/response/types.go similarity index 91% rename from implement/types.go rename to response/types.go index b69a33b..0dd1ecf 100644 --- a/implement/types.go +++ b/response/types.go @@ -1,4 +1,4 @@ -package implement +package response import ( "git.xdrm.io/go/aicra/err" diff --git a/server.go b/server.go index 2d98e2f..a2adfab 100644 --- a/server.go +++ b/server.go @@ -3,11 +3,11 @@ package aicra import ( "fmt" e "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/implement" "git.xdrm.io/go/aicra/internal/checker" "git.xdrm.io/go/aicra/internal/config" "git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/middleware" + "git.xdrm.io/go/aicra/response" "log" "net/http" ) @@ -124,7 +124,7 @@ func (s *Server) routeRequest(res http.ResponseWriter, httpReq *http.Request) { parameters["_SCOPE_"] = scope /* (3) Execute */ - response := callable(parameters, implement.NewResponse()) + response := callable(parameters, response.NewResponse()) /* (4) Extract http headers */ for k, v := range response.Dump() { diff --git a/util.go b/util.go index d6c1271..e3aceb1 100644 --- a/util.go +++ b/util.go @@ -3,9 +3,9 @@ package aicra import ( "encoding/json" "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/implement" "git.xdrm.io/go/aicra/internal/config" "git.xdrm.io/go/aicra/internal/request" + "git.xdrm.io/go/aicra/response" "log" "net/http" ) @@ -34,7 +34,7 @@ func httpRedirect(r http.ResponseWriter, loc string) { } // Prints an HTTP response -func httpPrint(r http.ResponseWriter, res implement.Response) { +func httpPrint(r http.ResponseWriter, res response.Response) { // get response data formattedResponse := res.Dump()