Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/dhax/go-base
/ functions
Functions
190 in github.com/dhax/go-base
⨍
Functions
190
◇
Types & classes
53
↓ 18 callers
Method
Render
Render sets the application-specific error code in AppCode.
auth/pwdless/errors.go:29
↓ 13 callers
Method
Render
Render sets the application-specific error code in AppCode.
api/app/errors.go:22
↓ 12 callers
Function
ErrUnauthorized
ErrUnauthorized renders status 401 Unauthorized with custom error message.
auth/pwdless/errors.go:35
↓ 11 callers
Method
Render
Render sets the application-specific error code in AppCode.
api/admin/errors.go:22
↓ 10 callers
Function
log
(r *http.Request)
auth/pwdless/api.go:83
↓ 8 callers
Method
Get
(accountID int)
api/app/profile.go:22
↓ 7 callers
Function
GetLogEntry
Helper methods used by the application to get the request-scoped logger entry and set additional fields between handlers. GetLogEntry return the reque
logging/logger.go:113
↓ 6 callers
Function
ErrUnauthorized
ErrUnauthorized renders status 401 Unauthorized with custom error message.
auth/jwt/errors.go:37
↓ 6 callers
Method
Render
Render sets the application-specific error code in AppCode.
auth/jwt/errors.go:31
↓ 5 callers
Method
Delete
(*pwdless.Account)
api/admin/accounts.go:28
↓ 5 callers
Function
ErrInvalidRequest
ErrInvalidRequest returns status 422 Unprocessable Entity including error message.
api/admin/errors.go:28
↓ 4 callers
Function
ErrInvalidRequest
ErrInvalidRequest returns status 422 Unprocessable Entity including error message.
api/app/errors.go:28
↓ 4 callers
Method
Get
(id int)
api/admin/accounts.go:26
↓ 4 callers
Method
Validate
Validate validates Account struct and returns validation errors.
auth/pwdless/account.go:51
↓ 4 callers
Function
testRequest
(t *testing.T, ts *httptest.Server, method, path string, body io.Reader, token string)
auth/pwdless/api_test.go:331
↓ 3 callers
Method
CanLogin
CanLogin returns true if user is allowed to login.
auth/pwdless/account.go:63
↓ 3 callers
Method
Claims
Claims returns the account's claims to be signed
auth/pwdless/account.go:68
↓ 3 callers
Function
ClaimsFromCtx
ClaimsFromCtx retrieves the parsed AppClaims from request context.
auth/jwt/authenticator.go:23
↓ 3 callers
Function
ErrRender
ErrRender returns status 422 Unprocessable Entity rendering response error.
api/app/errors.go:49
↓ 3 callers
Function
NewEmail
NewEmail returns an email address.
email/mailer.go:67
↓ 3 callers
Function
ParseStructToMap
(c any)
auth/jwt/tokenauth.go:79
↓ 3 callers
Function
newAccountResponse
(a *pwdless.Account)
api/admin/accounts.go:85
↓ 2 callers
Method
Bind
(r *http.Request)
auth/pwdless/api.go:91
↓ 2 callers
Method
Bind
(r *http.Request)
api/app/account.go:136
↓ 2 callers
Method
Bind
(r *http.Request)
api/admin/accounts.go:77
↓ 2 callers
Method
CreateOrUpdateToken
(t *jwt.Token)
auth/pwdless/api.go:31
↓ 2 callers
Method
CreateToken
CreateToken creates an in-memory login token referencing account ID. It returns a token containing a random tokenstring and expiry date.
auth/pwdless/logintoken.go:42
↓ 2 callers
Function
DBConn
DBConn returns a postgres connection pool.
database/postgres.go:16
↓ 2 callers
Method
DeleteToken
(t *jwt.Token)
auth/pwdless/api.go:32
↓ 2 callers
Function
ErrRender
ErrRender returns status 422 Unprocessable Entity rendering response error.
api/admin/errors.go:38
↓ 2 callers
Function
ErrValidation
ErrValidation returns status 422 Unprocessable Entity stating validation errors.
api/app/errors.go:38
↓ 2 callers
Function
ErrValidation
ErrValidation returns status 422 Unprocessable Entity stating validation errors.
api/admin/errors.go:48
↓ 2 callers
Method
GenTokenPair
GenTokenPair returns both an access token and a refresh token.
auth/jwt/tokenauth.go:53
↓ 2 callers
Method
GetAccount
(id int)
auth/pwdless/api.go:26
↓ 2 callers
Method
GetToken
(token string)
auth/pwdless/api.go:30
↓ 2 callers
Function
New
New configures application resources and routes.
api/api.go:25
↓ 2 callers
Function
NewLogger
NewLogger creates and configures a new logrus Logger.
logging/logger.go:24
↓ 2 callers
Function
NewMockMailer
()
email/mockMailer.go:15
↓ 2 callers
Function
NewResource
NewResource returns a configured authentication resource.
auth/pwdless/api.go:45
↓ 2 callers
Function
NewStructuredLogger
NewStructuredLogger implements a custom structured logrus Logger.
logging/logger.go:49
↓ 2 callers
Function
RefreshTokenFromCtx
RefreshTokenFromCtx retrieves the parsed refresh token from context.
auth/jwt/authenticator.go:28
↓ 2 callers
Method
Router
Router provides necessary routes for passwordless authentication flow.
auth/pwdless/api.go:69
↓ 2 callers
Method
Router
Router provides application routes.
api/app/api.go:44
↓ 2 callers
Method
Update
(p *models.Profile)
api/app/profile.go:23
↓ 2 callers
Method
UpdateAccount
(a *Account)
auth/pwdless/api.go:28
↓ 2 callers
Method
Verifier
Verifier http middleware will verify a jwt string from a http request.
auth/jwt/tokenauth.go:48
↓ 2 callers
Method
Write
(status, bytes int, header http.Header, elapsed time.Duration, extra any)
logging/logger.go:91
↓ 2 callers
Method
delete
(token string)
auth/pwdless/logintoken.go:76
↓ 2 callers
Function
encode
(v any)
auth/pwdless/api_test.go:372
↓ 2 callers
Function
genRefreshJWT
func genJWT(c jwt.AppClaims) string { claims, _ := jwt.ParseStructToMap(c) _, tokenString, _ := auth.TokenAuth.JwtAuth.Encode(claims) return tokenS
auth/pwdless/api_test.go:365
↓ 2 callers
Function
log
(r *http.Request)
api/app/api.go:53
↓ 2 callers
Function
newAccountResponse
(a *pwdless.Account)
api/app/account.go:91
↓ 2 callers
Function
newProfileResponse
(p *models.Profile)
api/app/profile.go:73
↓ 2 callers
Method
router
()
api/app/account.go:44
↓ 1 callers
Method
Apply
Apply applies an AccountFilter on a bun.SelectQuery.
database/admAccountStore.go:71
↓ 1 callers
Method
Bind
(r *http.Request)
api/app/profile.go:65
↓ 1 callers
Method
Claims
Claims returns the token claims to be signed
auth/jwt/token.go:39
↓ 1 callers
Method
Create
(*pwdless.Account)
api/admin/accounts.go:25
↓ 1 callers
Method
CreateJWT
CreateJWT returns an access token for provided account claims.
auth/jwt/tokenauth.go:66
↓ 1 callers
Method
CreateRefreshJWT
CreateRefreshJWT returns a refresh token for provided token Claims.
auth/jwt/tokenauth.go:91
↓ 1 callers
Method
DeleteToken
(*jwt.Token)
api/app/account.go:29
↓ 1 callers
Function
Execute
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the r
cmd/root.go:25
↓ 1 callers
Method
GetAccountByEmail
(email string)
auth/pwdless/api.go:27
↓ 1 callers
Method
GetAccountID
GetAccountID looks up the token by tokenstring and returns the account ID or error if token not found or expired.
auth/pwdless/logintoken.go:54
↓ 1 callers
Method
List
(*database.AccountFilter)
api/admin/accounts.go:24
↓ 1 callers
Function
LoginTokenEmail
LoginTokenEmail creates and sends a login token email with provided template content.
auth/pwdless/emails.go:20
↓ 1 callers
Function
Migrate
Migrate runs all migrations
database/migrations/main.go:25
↓ 1 callers
Function
NewAPI
NewAPI configures and returns application API.
api/app/api.go:29
↓ 1 callers
Function
NewAPI
NewAPI configures and returns admin application API.
api/admin/api.go:33
↓ 1 callers
Function
NewAccountFilter
NewAccountFilter returns an AccountFilter with options parsed from request url values.
database/admAccountStore.go:43
↓ 1 callers
Function
NewAccountResource
NewAccountResource creates and returns an account resource.
api/app/account.go:38
↓ 1 callers
Function
NewAccountResource
NewAccountResource creates and returns an account resource.
api/admin/accounts.go:37
↓ 1 callers
Function
NewAccountStore
NewAccountStore returns an AccountStore.
database/accountStore.go:19
↓ 1 callers
Function
NewAdmAccountStore
NewAdmAccountStore returns an AccountStore.
database/admAccountStore.go:28
↓ 1 callers
Function
NewAuthStore
NewAuthStore return an AuthStore.
database/authStore.go:18
↓ 1 callers
Function
NewLoginTokenAuth
NewLoginTokenAuth configures and returns a LoginToken authentication instance.
auth/pwdless/logintoken.go:31
↓ 1 callers
Function
NewMailer
NewMailer returns a configured SMTP Mailer.
email/smtp.go:15
↓ 1 callers
Function
NewProfileResource
NewProfileResource creates and returns a profile resource.
api/app/profile.go:32
↓ 1 callers
Function
NewProfileStore
NewProfileStore returns a ProfileStore implementation.
database/profileStore.go:17
↓ 1 callers
Function
NewServer
NewServer creates and configures an APIServer serving all application routes.
api/server.go:20
↓ 1 callers
Function
NewTokenAuth
NewTokenAuth configures and returns a JWT authentication instance.
auth/jwt/tokenauth.go:20
↓ 1 callers
Method
ParseClaims
ParseClaims parses JWT claims into AppClaims.
auth/jwt/claims.go:23
↓ 1 callers
Method
ParseClaims
ParseClaims parses the JWT claims into RefreshClaims.
auth/jwt/claims.go:60
↓ 1 callers
Method
PurgeExpiredToken
()
auth/pwdless/api.go:33
↓ 1 callers
Method
Render
Render sets the application-specific error code in AppCode.
auth/authorize/errors.go:20
↓ 1 callers
Function
RequiresRole
RequiresRole middleware restricts access to accounts having role parameter in their jwt claims.
auth/authorize/roles.go:13
↓ 1 callers
Function
SPAHandler
SPAHandler serves the public Single Page Application.
api/api.go:106
↓ 1 callers
Method
Send
(Message)
email/mailer.go:21
↓ 1 callers
Method
Start
Start runs ListenAndServe on the http.Server with graceful shutdown.
api/server.go:46
↓ 1 callers
Method
Update
(*pwdless.Account)
api/admin/accounts.go:27
↓ 1 callers
Method
UpdateToken
(*jwt.Token)
api/app/account.go:28
↓ 1 callers
Method
Validate
Validate validates Profile struct and returns validation errors.
models/profile.go:34
↓ 1 callers
Method
add
(lt LoginToken)
auth/pwdless/logintoken.go:70
↓ 1 callers
Function
checkConn
(db *bun.DB)
database/postgres.go:36
↓ 1 callers
Method
choresTicker
()
auth/pwdless/chores.go:9
↓ 1 callers
Function
corsConfig
()
api/api.go:90
↓ 1 callers
Function
genRoutesDoc
()
cmd/gendoc.go:49
↓ 1 callers
Method
get
(token string)
auth/pwdless/logintoken.go:63
↓ 1 callers
Function
hasRole
(role string, roles []string)
auth/authorize/roles.go:27
↓ 1 callers
Function
log
(r *http.Request)
api/admin/api.go:57
next →
1–100 of 190, ranked by callers