generated from denpeshkov/go-template
-
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.
add authentication; refactoring and bugs fixing
- Loading branch information
1 parent
89e5139
commit c68f5a2
Showing
6 changed files
with
76 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package greenlight | ||
|
||
import "context" | ||
|
||
type ctxKey string | ||
|
||
const ( | ||
userIDCtxKey ctxKey = "userID" | ||
) | ||
|
||
func NewContextWithUserID(ctx context.Context, userID int64) context.Context { | ||
return context.WithValue(ctx, userIDCtxKey, userID) | ||
} | ||
|
||
func UserIDFromContext(ctx context.Context) int64 { | ||
userID, _ := ctx.Value(userIDCtxKey).(int64) | ||
return userID | ||
} |
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
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