libcgi

package
v0.0.0-...-e1ab6f8 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

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

Examples

Constants

View Source
const Klen = 300

Variables

View Source
var Home string

Functions

func AddUser

func AddUser(admin, akey, user, ukey, level string)

Admin level is "0". Send to client ok

func Authentication

func Authentication(user, key string, expiration bool)

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 ChangePass

func ChangePass(user, key, newKey string)

Send to clien 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 DelUser

func DelUser(admin, akey, user string)

Admin level is "0". Send to client ok

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

func GetPageIdKey(sessionId string) (pageId, key string)

Returns pageId and key. If conection failed both are ""

func Init

func Init(home string, texpiration int64)

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"}

func SetKey

func SetKey(k string)

SetKey sets the key which 'Ok' and 'Err' will use

Types

This section is empty.

Directories

Path Synopsis
Utilities to easy input-output
Utilities to easy input-output
Cryptographic utilities
Cryptographic utilities

Jump to

Keyboard shortcuts

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