first commit - half test with: +config +controllers -no_custom_type
This commit is contained in:
commit
2ba1d6e2a1
|
@ -0,0 +1 @@
|
|||
*.so
|
|
@ -0,0 +1,36 @@
|
|||
# xdrm go framework
|
||||
|
||||
### 1. Setup
|
||||
|
||||
All commands above must be launched from the root of this repository.
|
||||
|
||||
In order for next steps to work properly whatever your configuration, you might execute the following command:
|
||||
```bash
|
||||
chmod +x $GOPATH/src/git.xdrm.io/xdrm-brackets/gfw/*.sh
|
||||
```
|
||||
|
||||
### 2. Build type checkers
|
||||
|
||||
Default types have to be built before using them.
|
||||
|
||||
```bash
|
||||
$GOPATH/src/git.xdrm.io/xdrm-brackets/gfw/build-types.sh
|
||||
```
|
||||
|
||||
If the build process succeeds, the `./types` folder must contain *.so* files.
|
||||
|
||||
### 3. Build controllers
|
||||
|
||||
Controllers are located under the `./root` file structure.
|
||||
|
||||
```bash
|
||||
$GOPATH/src/git.xdrm.io/xdrm-brackets/gfw/build-controllers.sh ./root
|
||||
```
|
||||
|
||||
If the build process succeeds, the `./controllers` folder must contain *.so* files.
|
||||
|
||||
### 4. Launch the api
|
||||
|
||||
```
|
||||
$ go run ./cmd/test/main.go
|
||||
```
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"git.xdrm.io/xdrm-brackets/gfw"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
srv, err := gfw.Init("manifest.json", nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Printf("Server up and running\n")
|
||||
err = srv.Launch(4444)
|
||||
if err != nil {
|
||||
log.Fatalf("*** server failed (%s)\n", err)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
{
|
||||
|
||||
"GET": {
|
||||
"info": "returns api information",
|
||||
"scope": [[]],
|
||||
"in": {},
|
||||
"out": {
|
||||
"version": { "info": "current api version", "type": "varchar(1,8)" },
|
||||
"info": { "info": "api information details", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"/": {
|
||||
|
||||
"user": {
|
||||
|
||||
"GET": {
|
||||
"info": "gets all | a specific user by id",
|
||||
"scope": [[]],
|
||||
"in": {
|
||||
"URL#0": { "info": "optional user id | all users are returned if missing", "name": "uid", "type": "?int", "default": null }
|
||||
},
|
||||
"out": {
|
||||
"users": { "info": "matching user(s) data", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"POST": {
|
||||
"info": "creates a new user",
|
||||
"scope": [["admin"]],
|
||||
"in": {
|
||||
"firstname": { "info": "new first name", "type": "varchar(3,20)" },
|
||||
"lastname": { "info": "new last name", "type": "varchar(3,20)" },
|
||||
"mail": { "info": "new mail", "type": "string" }
|
||||
},
|
||||
"out": {
|
||||
"user": { "info": "user data to acknowledge creation", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"PUT": {
|
||||
"info": "updates data of an existing user; only the data given will be updated, all fields are optional",
|
||||
"scope": [["admin"], ["user"]],
|
||||
"in": {
|
||||
"URL#0": { "info": "id of the user to update", "type": "int", "name": "user_id" },
|
||||
"firstname": { "info": "new first name", "type": "?varchar(3,20)", "default": null },
|
||||
"lastname": { "info": "new last name", "type": "?varchar(3,20)", "default": null },
|
||||
"mail": { "info": "new mail", "type": "?string", "default": null }
|
||||
},
|
||||
"out": {
|
||||
"user": { "info": "new updated data to acknowledge updates", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"DELETE": {
|
||||
"info": "deletes an existing user",
|
||||
"scope": [["admin"], ["user"]],
|
||||
"in": {
|
||||
"URL#0": { "info": "id of the user to delete", "type": "int" }
|
||||
},
|
||||
"out": {}
|
||||
},
|
||||
|
||||
"/": {
|
||||
"post": {
|
||||
"GET": {
|
||||
"info": "gets all | a specific post for an existing user",
|
||||
"scope": [["user"], []],
|
||||
"in": {
|
||||
"URL#0": { "info": "optional post id", "type": "int", "name": "?post_id", "default": null },
|
||||
"URL#1": { "info": "user id (if missing, current connected user)", "type": "int", "name": "?user_id", "default": null }
|
||||
},
|
||||
"out": {
|
||||
"posts": { "info": "matching post(s) data", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"POST": {
|
||||
"info": "creates a new post for the current connected user",
|
||||
"scope": [["user"]],
|
||||
"in": {
|
||||
"title": { "info": "new post title", "type": "varchar(3,20)" },
|
||||
"content": { "info": "new post content", "type": "string" }
|
||||
},
|
||||
"out": {
|
||||
"post": { "info": "post data to acknowledge creation", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"PUT": {
|
||||
"info": "updates data of an existing post of the current connected user; only the data given will be updated, all fields are optional",
|
||||
"scope": [["user"]],
|
||||
"in": {
|
||||
"title": { "info": "new post title", "type": "?varchar(3,20)", "default": null },
|
||||
"content": { "info": "new post content", "type": "?string", "default": null }
|
||||
},
|
||||
"out": {
|
||||
"post": { "info": "new updated data to acknowledge updates", "type": "<any>" }
|
||||
}
|
||||
},
|
||||
|
||||
"DELETE": {
|
||||
"info": "deletes an existing post of the current connected user",
|
||||
"scope": [["user"]],
|
||||
"in": {
|
||||
"URL#0": { "info": "id of the post to delete", "type": "int", "name": "post_id" }
|
||||
},
|
||||
"out": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
e "git.xdrm.io/xdrm-brackets/gfw/err"
|
||||
i "git.xdrm.io/xdrm-brackets/gfw/implement"
|
||||
)
|
||||
|
||||
func Get(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("GET /\n")
|
||||
r.Set("api_version", 1.2)
|
||||
r.Set("received_data", d)
|
||||
r.Err = e.Success
|
||||
return *r
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
e "git.xdrm.io/xdrm-brackets/gfw/err"
|
||||
i "git.xdrm.io/xdrm-brackets/gfw/implement"
|
||||
)
|
||||
|
||||
func Get(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("GET /user/post\n")
|
||||
r.Set("method_test", "Get")
|
||||
r.Err = e.Upload
|
||||
return *r
|
||||
}
|
||||
func Post(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("POST /user/post\n")
|
||||
r.Set("method_test", "Post")
|
||||
r.Err = e.Download
|
||||
return *r
|
||||
}
|
||||
func Put(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("PUT /user/post\n")
|
||||
r.Set("method_test", "Put")
|
||||
r.Err = e.MissingDownloadHeaders
|
||||
return *r
|
||||
}
|
||||
func Delete(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("DELETE /user/post\n")
|
||||
r.Set("method_test", "Delete")
|
||||
r.Err = e.MissingDownloadBody
|
||||
return *r
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
e "git.xdrm.io/xdrm-brackets/gfw/err"
|
||||
i "git.xdrm.io/xdrm-brackets/gfw/implement"
|
||||
)
|
||||
|
||||
func Get(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("GET /user\n")
|
||||
r.Set("method_test", "Get")
|
||||
r.Set("received_data", d)
|
||||
r.Err = e.Upload
|
||||
return *r
|
||||
}
|
||||
func Post(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("POST /user\n")
|
||||
r.Set("method_test", "Post")
|
||||
r.Set("received_data", d)
|
||||
r.Err = e.Download
|
||||
return *r
|
||||
}
|
||||
func Put(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("PUT /user\n")
|
||||
r.Set("method_test", "Put")
|
||||
r.Set("received_data", d)
|
||||
r.Err = e.MissingDownloadHeaders
|
||||
return *r
|
||||
}
|
||||
func Delete(d i.Arguments, r *i.Response) i.Response {
|
||||
fmt.Printf("DELETE /user\n")
|
||||
r.Set("method_test", "Delete")
|
||||
r.Set("received_data", d)
|
||||
r.Err = e.MissingDownloadBody
|
||||
return *r
|
||||
}
|
Loading…
Reference in New Issue