Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit e054cd2

Browse files
author
Josh Cave
committed
site ulid
1 parent ee4ac64 commit e054cd2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

flow.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"strings"
1313

14+
"github.com/oklog/ulid"
1415
log "github.com/sirupsen/logrus"
1516

1617
"github.com/go-zoo/bone"
@@ -67,7 +68,11 @@ func (c *Context) WebsiteBaseURL() string {
6768
}
6869

6970
func (c *Context) SiteID() int {
70-
return c.Padlock.SiteID() // short hand... will panic if used improperly
71+
return c.Padlock.SiteID()
72+
}
73+
74+
func (c *Context) SiteULID() int {
75+
return c.Padlock.SiteULID()
7176
}
7277

7378
// func (c *Context) GetCacheValue(key string) (string, error) {
@@ -145,6 +150,15 @@ func (ctx *Context) URLIntValues(key string) ([]int, error) {
145150
return ints, nil
146151
}
147152

153+
func (ctx *Context) URLULIDParam(key string) (string, error) {
154+
ul := strings.ToUpper(ctx.URLParam(key))
155+
id, err := ulid.Parse(ul)
156+
if err != nil {
157+
return "", err
158+
}
159+
return id.String(), nil
160+
}
161+
148162
func (ctx *Context) URLParam(key string) string {
149163
// try route param
150164
value := bone.GetValue(ctx.Req, key)

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/nerdynz/flow
2+
3+
go 1.14

0 commit comments

Comments
 (0)