dynamic-querys-go

command module
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 10 Imported by: 0

README

DynamicQuerysGo / GoActions

Intro

DynamicQuerysGo is a simple API project written in go, whith the intent to simulate a GraphQL like experience, in terms of interacting with the back-end of the service. Here a request is called an action, which represents both an mutation and a query, the main purpose of these actions is to resolve actions/requests to function calls, in a quick and simple way.

What I plan to add - (updated)

  1. DONE! Reduce the request/action foot-print, sent to the server. Make it more readable, like graph, or a docker compose file, type of readable.

  2. DONE! Make my own request parser to suport objective one.

Things to keep in mind - v.1.1-Release

Settings:

  1. The port where the server is located defaults to 8000, but it also reads from the enviorment variable ENV_GOACTIONS_PORT

Since DynamicQuerysGo is based arround a custom request schema (like in graph), conssider the following:

  1. Any form of rquest authentication, should be implemented by the user, the idea is to use JWT, keep in mind that the auth fiedl only takes strings

  2. The beginning of the request sholud have the action: keyword, other wise the no functions will be called, and the action body will not be parssed.

  3. The function calls are deffined by the format "funcName": and the parameters to be passed are written in the lines bellow, one line per each parameter, and the paremeters are declared similarly as json values ending the line with a semicolon, ex:

    Variable type Variable value
    Integers 1234,
    Strings "Muck Nuck",
    Float64 142.6356,
    Booleans true / false
    map[string]interface{} (to decode json) {"name":"Muck Nuck"}, or {\"name\":\"Tomás\"},
    [ ]interface{} (multi/single type arrays) [1231,14.13,true,"asdasd",{"name":"Muck Nuck"},],
  4. The action schema should be written in the following these steps:

    • First line is for the keyword action:.
    • Second line can ommit the auth: field, your choice
    • The function calls are specified by "functionName": and the next lines are the arguments, one line per each argument passed.
    • The only indentation to worry about is in the paremeter passing for functions, you could write the action with no indentation but the parameters need to be in their own singular lines.

Examples

Action calling function ReverseString: (action schema oriented)

action:
    auth: "JWT EXAMPLE" // optional
    funcs:
        "ReverseString":
            "Hello GO",

OR

action:
auth: "JWT EXAMPLE"
funcs:
"ReverseString":
"Hello GO",

Action calling multiple funcs: (action schema oriented)

action:
    auth: "JWT EXAMPLE" // optional
    funcs:
        "ReverseString":
            "Hello GO",
        "ReverseStringBool":
            true,
            "Hello GO", 
        "TakeAnInterfaceArray":
            [1231,14.13,true,"Muck","Nuck","{\\"name\\":123124}",],
        "TakeAMap":
            {"age":43},

Result: (json)

{
    "ReverseString": [
        {
            "reverssed": "OG olleH"
        }
    ],
    "ReverseStringBool": [
        {
            "reversse": true,
            "reverssed": "OG olleH"
        }
    ],
    "TakeAMap": [
        {
            "age": 43
        }
    ],
    "TakeAnInterfaceArray": [
        [
            1231,
            14.13,
            true,
            "asdasd",
            "asdasd",
            {
                "name": 123124
            }
        ]
    ]
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL