rename 'implement' into 'response'
This commit is contained in:
parent
6784c2df95
commit
07bbdbbe30
|
@ -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)
|
||||
}
|
||||
```
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package implement
|
||||
package response
|
||||
|
||||
// Checks whether a key exists in the arguments
|
||||
func (i Arguments) Has(key string) bool {
|
|
@ -1,4 +1,4 @@
|
|||
package implement
|
||||
package response
|
||||
|
||||
import (
|
||||
"git.xdrm.io/go/aicra/err"
|
|
@ -1,4 +1,4 @@
|
|||
package implement
|
||||
package response
|
||||
|
||||
import (
|
||||
"git.xdrm.io/go/aicra/err"
|
|
@ -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() {
|
||||
|
|
4
util.go
4
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue