Skip to content

Commit c4bfa07

Browse files
authored
feat: add util to http handler, support to parse bool parameter (#58)
* feat: add util to parse bool parameter * chore: update release notes
1 parent 574d55c commit c4bfa07

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

core/api/handler.go

+11
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@ func (handler Handler) GetIntOrDefault(r *http.Request, key string, defaultValue
256256
}
257257
return s
258258

259+
}
260+
func (handler Handler) GetBoolOrDefault(r *http.Request, key string, defaultValue bool) bool {
261+
262+
v := strings.ToLower(handler.GetParameter(r, key))
263+
if v=="false"{
264+
return false
265+
}else if v=="true"{
266+
return true
267+
}
268+
return defaultValue
269+
259270
}
260271

261272
// GetJSON return json input

docs/content.en/docs/release-notes/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Information about release notes of INFINI Framework is provided here.
1313
### Features
1414
### Bug fix
1515
### Improvements
16+
- Add util to http handler, support to parse bool parameter
1617

1718
## v1.1.0 (2025-01-11)
1819

0 commit comments

Comments
 (0)