-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ConductorOne/lauren/check-total-paginatio…
…n-offset Check total count header when generating pagination offset
- Loading branch information
Showing
3 changed files
with
44 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package servicenow | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
"text/template" | ||
) | ||
|
||
type URLParams map[string]string | ||
|
||
func GenerateURL(baseURL string, params URLParams) (string, error) { | ||
tmpl, err := template.New("url").Parse(baseURL) | ||
if err != nil { | ||
return "", err | ||
} | ||
var urlBuilder strings.Builder | ||
err = tmpl.Execute(&urlBuilder, params) | ||
if err != nil { | ||
return "", err | ||
} | ||
return urlBuilder.String(), nil | ||
} | ||
|
||
func ConvertPageToken(token string) (int, error) { | ||
if token == "" { | ||
return 0, nil | ||
} | ||
return strconv.Atoi(token) | ||
} |