rename 'implement' into 'response'
This commit is contained in:
parent
6784c2df95
commit
07bbdbbe30
|
@ -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).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
|
@ -1,4 +1,4 @@
|
||||||
package implement
|
package response
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.xdrm.io/go/aicra/err"
|
"git.xdrm.io/go/aicra/err"
|
|
@ -1,4 +1,4 @@
|
||||||
package implement
|
package response
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.xdrm.io/go/aicra/err"
|
"git.xdrm.io/go/aicra/err"
|
|
@ -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() {
|
||||||
|
|
4
util.go
4
util.go
|
@ -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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue