Documentation
¶
Overview ¶
Management of HXMLRequest in the server side.
Initialization ¶
Before using libcgi is necesary call libcgi.Init.
After that you must call libcgi.SetKey before do it to libcgi.Ok or libcig.Err. (see https://github.com/dedeme/go/blob/master/JsDoc/JsDoc.go)
Index ¶
- Constants
- Variables
- func AddUser(admin, akey, user, ukey, level string)
- func Authentication(user, key string, expiration bool)
- func ChangeLevel(admin, akey, user, level string)
- func ChangePass(user, key, newKey string)
- func Connect(sessionId string)
- func DelSession(sessionId string)
- func DelUser(admin, akey, user string)
- func Err(msg string)
- func Expired()
- func GetPageIdKey(sessionId string) (pageId, key string)
- func Init(home string, texpiration int64)
- func Ok(rp map[string]interface{})
- func SetKey(k string)
Examples ¶
Constants ¶
const Klen = 300
Variables ¶
var Home string
Functions ¶
func AddUser ¶
func AddUser(admin, akey, user, ukey, level string)
Admin level is "0". Send to client ok
func Authentication ¶
Send to client level, key, pageId and sessionI, If authentication failed every value is "".
func ChangeLevel ¶
func ChangeLevel(admin, akey, user, level string)
Admin level is "0". Send to client ok
func Connect ¶
func Connect(sessionId string)
Send to client pageId and key. If conection failed both are ""
func DelSession ¶
func DelSession(sessionId string)
func Err ¶
func Err(msg string)
Err sends an error message to client. The message is a JSON object of type:
{error:msg}
Example ¶
r, err := b64.DecodeString("eyJlcnJvciI6IkEgZmFpbCJ9")
if err != nil {
panic(err.Error())
}
fmt.Println()
fmt.Println(string(r))
// {"error":"A fail"}
func Expired ¶
func Expired()
Expired sends a expiration message to client. The message is a JSON object:
{expired:true}
func GetPageIdKey ¶
Returns pageId and key. If conection failed both are ""
func Init ¶
Init initializes libcgi. 'texpiration' is in seconds.
When application is initialized for the first time, 'home' must no exist.
func Ok ¶
func Ok(rp map[string]interface{})
Ok sends a response ('rp') to client. It adds a field rp["error"] = "".
Example ¶
Init("a", "b")
rp := make(map[string]interface{})
rp["name"] = "Peter"
rp["age"] = 23
Ok(rp)
r, err := b64.DecodeString("eyJhZ2UiOjIzLCJlcnJvciI6IiIsIm5hbWUiOiJQZXRlciJ9")
if err != nil {
panic(err.Error())
}
fmt.Println()
fmt.Println(cryp.Key("deme", 300))
fmt.Println(string(r))
fmt.Print(cryp.Decryp("b",
"m++Vu56Dq71/nX+ypbartbPToeKnw5eXf92vzK7Hq9u0uJ+ghMGBpq2Oir+5sYKL"))
Output: m++Vu56Dq71/nX+ypbartbPToeKnw5eXf92vzK7Hq9u0uJ+ghMGBpq2Oir+5sYKL {"age":23,"error":"","name":"Peter"} {"age":23,"error":"","name":"Peter"}
Types ¶
This section is empty.