Add HttpPost
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
if ifc == nil {
|
||||
return nil, errors.New("Undefine variable " + idx);
|
||||
return nil, errors.New("Undefine variable '" + idx + "'");
|
||||
}
|
||||
|
||||
// app.Log("Found ifc %s %T", idx, ifc)
|
||||
@@ -43,25 +43,73 @@
|
||||
return app.IfcGet(app.Conf, arr...);
|
||||
}
|
||||
|
||||
func (app *App) ConfGetStr(arr ...string) (string, error) {
|
||||
ifc, err := app.ConfGetIfc(arr...);
|
||||
|
||||
func (app *App) IfcGetStr(ifc0 interface{}, arr ...string) (string, error) {
|
||||
ifc, err := app.IfcGet(ifc0, arr...)
|
||||
|
||||
if err != nil {
|
||||
return "", err;
|
||||
app.Log(err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
switch ifc.(type) {
|
||||
case string:
|
||||
return ifc.(string), nil;
|
||||
|
||||
case float64:
|
||||
f := ifc.(float64)
|
||||
u := uint64(f)
|
||||
return strconv.FormatUint(u, 10), nil;
|
||||
default:
|
||||
return "", errors.New("Invalid type value !s");
|
||||
|
||||
case bool:
|
||||
if ifc.(bool) {
|
||||
return "true", nil
|
||||
}
|
||||
|
||||
return "false", nil
|
||||
}
|
||||
|
||||
return "", errors.New("Invalid type value");
|
||||
return "", errors.New("Invalid type value not string or float64/bool");
|
||||
}
|
||||
|
||||
func (app *App) ConfGetStr(arr ...string) (string, error) {
|
||||
return app.IfcGetStr(app.Conf, arr...)
|
||||
}
|
||||
|
||||
func (app *App) IfcGetFlt(ifc0 interface{}, arr ...string) (float64, error) {
|
||||
ifc, err := app.IfcGet(ifc0, arr...)
|
||||
|
||||
if err != nil {
|
||||
app.Log(err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
switch ifc.(type) {
|
||||
case string:
|
||||
flt, err := strconv.ParseFloat(ifc.(string), 64)
|
||||
|
||||
if err != nil {
|
||||
app.Log(err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return flt, nil;
|
||||
case float64:
|
||||
return ifc.(float64), nil;
|
||||
|
||||
case bool:
|
||||
if ifc.(bool) {
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
return 0, errors.New("Invalid type value not float64 or string/bool");
|
||||
}
|
||||
|
||||
func (app *App) ConfGetFlt(arr ...string) (float64, error) {
|
||||
return app.IfcGetFlt(app.Conf, arr...)
|
||||
}
|
||||
|
||||
func (app *App) ConfGetArr(arr ...string) ([]interface{}, error) {
|
||||
|
Reference in New Issue
Block a user