rename 'implement' into 'response'

This commit is contained in:
Adrien Marquès 2018-07-09 00:15:29 +02:00
parent 6784c2df95
commit 07bbdbbe30
7 changed files with 14 additions and 14 deletions

View File

@ -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. 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. **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 ##### 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 #### 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`. Usage is `aicra [options] /path/to/your/project`.
@ -158,7 +158,7 @@ import "git.xdrm.io/go/aicra"
func main() { func main() {
server, err := aicra.New("manifest.json") server, err := aicra.New("manifest.json")
if err != nil { return } if err != nil { return }
server.Listen(4242) server.Listen(4242)
} }
``` ```

View File

@ -3,7 +3,7 @@ package request
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"git.xdrm.io/go/aicra/implement" "git.xdrm.io/go/aicra/response"
"log" "log"
"net/http" "net/http"
"plugin" "plugin"
@ -93,7 +93,7 @@ func FetchFormData(req *http.Request) map[string]interface{} {
// LoadController tries to load a controller from its uri // LoadController tries to load a controller from its uri
// checks for its given method ('Get', 'Post', 'Put', or 'Delete') // 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 */ /* (1) Build controller path */
path := strings.Join(i.Path, "-") path := strings.Join(i.Path, "-")
@ -121,7 +121,7 @@ func (i *Request) LoadController(method string) (func(implement.Arguments, *impl
} }
/* (4) Check signature */ /* (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 { if !validSignature {
return nil, fmt.Errorf("Invalid signature for method %s", method) return nil, fmt.Errorf("Invalid signature for method %s", method)
} }

View File

@ -1,4 +1,4 @@
package implement package response
// Checks whether a key exists in the arguments // Checks whether a key exists in the arguments
func (i Arguments) Has(key string) bool { func (i Arguments) Has(key string) bool {

View File

@ -1,4 +1,4 @@
package implement package response
import ( import (
"git.xdrm.io/go/aicra/err" "git.xdrm.io/go/aicra/err"

View File

@ -1,4 +1,4 @@
package implement package response
import ( import (
"git.xdrm.io/go/aicra/err" "git.xdrm.io/go/aicra/err"

View File

@ -3,11 +3,11 @@ package aicra
import ( import (
"fmt" "fmt"
e "git.xdrm.io/go/aicra/err" 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/checker"
"git.xdrm.io/go/aicra/internal/config" "git.xdrm.io/go/aicra/internal/config"
"git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/internal/request"
"git.xdrm.io/go/aicra/middleware" "git.xdrm.io/go/aicra/middleware"
"git.xdrm.io/go/aicra/response"
"log" "log"
"net/http" "net/http"
) )
@ -124,7 +124,7 @@ func (s *Server) routeRequest(res http.ResponseWriter, httpReq *http.Request) {
parameters["_SCOPE_"] = scope parameters["_SCOPE_"] = scope
/* (3) Execute */ /* (3) Execute */
response := callable(parameters, implement.NewResponse()) response := callable(parameters, response.NewResponse())
/* (4) Extract http headers */ /* (4) Extract http headers */
for k, v := range response.Dump() { for k, v := range response.Dump() {

View File

@ -3,9 +3,9 @@ package aicra
import ( import (
"encoding/json" "encoding/json"
"git.xdrm.io/go/aicra/err" "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/config"
"git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/internal/request"
"git.xdrm.io/go/aicra/response"
"log" "log"
"net/http" "net/http"
) )
@ -34,7 +34,7 @@ func httpRedirect(r http.ResponseWriter, loc string) {
} }
// Prints an HTTP response // Prints an HTTP response
func httpPrint(r http.ResponseWriter, res implement.Response) { func httpPrint(r http.ResponseWriter, res response.Response) {
// get response data // get response data
formattedResponse := res.Dump() formattedResponse := res.Dump()