| 1404 | } |
| 1405 | |
| 1406 | func homeModelInt64Value(model map[string]any, keys ...string) int64 { |
| 1407 | for _, key := range keys { |
| 1408 | switch value := model[key].(type) { |
| 1409 | case float64: |
| 1410 | return int64(value) |
| 1411 | case int64: |
| 1412 | return value |
| 1413 | case int: |
| 1414 | return int64(value) |
| 1415 | case json.Number: |
| 1416 | if n, errInt := value.Int64(); errInt == nil { |
| 1417 | return n |
| 1418 | } |
| 1419 | case string: |
| 1420 | if n, errParse := strconv.ParseInt(strings.TrimSpace(value), 10, 64); errParse == nil { |
| 1421 | return n |
| 1422 | } |
| 1423 | } |
| 1424 | } |
| 1425 | return 0 |
| 1426 | } |
| 1427 | |
| 1428 | // Start begins listening for and serving HTTP or HTTPS requests. |
| 1429 | // It's a blocking call and will only return on an unrecoverable error. |