merge
This commit is contained in:
commit
be1ceb07a2
|
@ -108,7 +108,7 @@ A sample file can be found [here](https://git.xdrm.io/example/aicra/src/master/a
|
||||||
|
|
||||||
###### Example
|
###### Example
|
||||||
|
|
||||||
In this example we have the controllers inside the `controller` folder, the middle-wares in the `middleware` folder and custom type checkers inside the `checker` folder, we want to load the built-in type checkers and are using the `plugin` driver. Also our project root is the relative current path `.` ; note that it is better using an absolute path as your project root.
|
In this example we have the controllers inside the `controller` folder, the middle-wares in the `middleware` folder and custom type checkers inside the `checker` folder, we want to load the built-in type checkers and are using the `plugin` driver. Also our project root is the relative current path `.` ; note that it is better using an absolute path as your project root.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ The `in` field in each method contains as list of arguments where the key is the
|
||||||
|
|
||||||
> Variable names must be <u>prefixed</u> when requesting **URI** or **Query** input types.
|
> Variable names must be <u>prefixed</u> when requesting **URI** or **Query** input types.
|
||||||
>
|
>
|
||||||
> - The first **URI** data has to be named `URL#0`, the second one `URL#1` and so on...
|
> - The first **URI** data has to be named `URL#0`, the second one `URL#1` and so on...
|
||||||
> - The variable named `somevar` in the **Query** has to be named `GET@somvar` in the configuration.
|
> - The variable named `somevar` in the **Query** has to be named `GET@somvar` in the configuration.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
|
@ -116,7 +116,7 @@ The documentation consists of directions for how to compile and run the project
|
||||||
"driver": "<driver>",
|
"driver": "<driver>",
|
||||||
"types": {
|
"types": {
|
||||||
"default": true,
|
"default": true,
|
||||||
"folder": "<custom-types-folder>"
|
"folder": "<custom-types-folder>"
|
||||||
},
|
},
|
||||||
"controllers": {
|
"controllers": {
|
||||||
"folder": "<controllers-folder"
|
"folder": "<controllers-folder"
|
||||||
|
@ -130,7 +130,7 @@ The documentation consists of directions for how to compile and run the project
|
||||||
**Note**: The following fields are optional :
|
**Note**: The following fields are optional :
|
||||||
|
|
||||||
- `types.default` is by default "types"
|
- `types.default` is by default "types"
|
||||||
-
|
-
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ func (tm TokenManager) Inspect(req http.Request, scope *[]string) {
|
||||||
if !isTokenValid(token) {
|
if !isTokenValid(token) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
scope = append(scope, getTokenPermissions(token)...)
|
scope = append(scope, getTokenPermissions(token)...)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -351,14 +351,14 @@ type UserController interface{}
|
||||||
|
|
||||||
func (ctl UserController) Get(args response.Arguments) response.Response {
|
func (ctl UserController) Get(args response.Arguments) response.Response {
|
||||||
res := response.New()
|
res := response.New()
|
||||||
|
|
||||||
// extract user ID argument
|
// extract user ID argument
|
||||||
user_id, ok := args["user_id"].(float64)
|
user_id, ok := args["user_id"].(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
res.Err = e.Failure
|
res.Err = e.Failure
|
||||||
return *res
|
return *res
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch user data
|
// fetch user data
|
||||||
res.Set("user", getUserData(user_id))
|
res.Set("user", getUserData(user_id))
|
||||||
return res
|
return res
|
||||||
|
@ -366,16 +366,16 @@ func (ctl UserController) Get(args response.Arguments) response.Response {
|
||||||
|
|
||||||
func (ctl UserController) Post(args response.Arguments) response.Response {
|
func (ctl UserController) Post(args response.Arguments) response.Response {
|
||||||
res := response.New()
|
res := response.New()
|
||||||
|
|
||||||
// extract user ID argument
|
// extract user ID argument
|
||||||
username, ok := args["username"].(string)
|
username, ok := args["username"].(string)
|
||||||
password, ok1 := args["password"].(string)
|
password, ok1 := args["password"].(string)
|
||||||
|
|
||||||
if !ok || !ok1 {
|
if !ok || !ok1 {
|
||||||
res.Err = e.Failure
|
res.Err = e.Failure
|
||||||
return *res
|
return *res
|
||||||
}
|
}
|
||||||
|
|
||||||
// store user data
|
// store user data
|
||||||
res.Set("created", storeUser(username, password))
|
res.Set("created", storeUser(username, password))
|
||||||
return res
|
return res
|
||||||
|
@ -391,7 +391,7 @@ func (ctl UserController) Post(args response.Arguments) response.Response {
|
||||||
|
|
||||||
Each type checker checks http request extracted values according to the type given in the api definition.
|
Each type checker checks http request extracted values according to the type given in the api definition.
|
||||||
|
|
||||||
The default types below are available in the `$GOPATH/src/git.xdrm.io/go/aicra/internal/checker/default`, they are loaded by default in any project. You can choose not to load them by settings `types`.`default` to `false` in the project configuration. To add custom types you must implement the [driver.Checker](https://godoc.org/git.xdrm.io/go/aicra/driver#Checker) interface and export it in order for aicra to dynamically load it.
|
The default types below are available in the `$GOPATH/src/git.xdrm.io/go/aicra/internal/checker/default`, they are loaded by default in any project. You can choose not to load them by settings `types`.`default` to `false` in the project configuration. To add custom types you must implement the [driver.Checker](https://godoc.org/git.xdrm.io/go/aicra/driver#Checker) interface and export it in order for aicra to dynamically load it.
|
||||||
|
|
||||||
## **1** - Default types
|
## **1** - Default types
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue