diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2021-08-18 17:13:25 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2021-08-18 17:13:25 -0600 |
commit | bec64827d19d64aae86ca3d2b26de800b427a540 (patch) | |
tree | 43aaf5b4b3681cff8e624819f311d8d36e9bd27f /srv/api/utils.go | |
parent | eaccf41563a5696996c0c75ceff1f270e88fc207 (diff) |
implement basic chat history endpoint
Diffstat (limited to 'srv/api/utils.go')
-rw-r--r-- | srv/api/utils.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/srv/api/utils.go b/srv/api/utils.go index 8e2a63b..7662e17 100644 --- a/srv/api/utils.go +++ b/srv/api/utils.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "net/http" + "strconv" "github.com/mediocregopher/mediocre-go-lib/v2/mlog" ) @@ -58,3 +59,10 @@ func internalServerError(rw http.ResponseWriter, r *http.Request, err error) { Error: "internal server error", }) } + +func strToInt(str string, defaultVal int) (int, error) { + if str == "" { + return defaultVal, nil + } + return strconv.Atoi(str) +} |