Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/demo-apps/go-gin-app
/ functions
Functions
65 in github.com/demo-apps/go-gin-app
⨍
Functions
65
◇
Types & classes
2
↓ 26 callers
Function
getRouter
Helper function to create a router during testing
common_test.go:25
↓ 16 callers
Function
ensureNotLoggedIn
This middleware ensures that a request will be aborted with an error if the user is already logged in
middleware.auth.go:28
↓ 9 callers
Function
ensureLoggedIn
This middleware ensures that a request will be aborted with an error if the user is not logged in
middleware.auth.go:13
↓ 9 callers
Function
testHTTPResponse
Helper function to process a request and test its response
common_test.go:35
↓ 8 callers
Function
render
Render one of HTML, JSON or CSV based on the 'Accept' header of the request If the header doesn't specify this, HTML is rendered, provided that the te
main.go:34
↓ 6 callers
Function
isUserValid
Check if the username and password combination is valid
models.user.go:28
↓ 5 callers
Function
registerNewUser
Register a new user with the given username and password NOTE: For this demo, we
models.user.go:39
↓ 4 callers
Function
getAllArticles
Return a list of all the articles
models.article.go:22
↓ 4 callers
Function
isUsernameAvailable
Check if the supplied username is available
models.user.go:54
↓ 4 callers
Function
setLoggedIn
This is a middleware that will set the value of "is_logged_in" to true or false depending on the value passed in. This is used only for testing
middleware.auth_test.go:121
↓ 4 callers
Function
setUserStatus
This middleware sets whether the user is logged in or not
middleware.auth.go:42
↓ 4 callers
Function
testMiddlewareRequest
This is a helper function that allows us to reuse some code in the above test methods
common_test.go:50
↓ 3 callers
Function
getLoginPOSTPayload
()
handlers.user_test.go:303
↓ 3 callers
Function
getRegistrationPOSTPayload
()
handlers.user_test.go:311
↓ 3 callers
Function
restoreLists
This function is used to restore the main lists from the temporary one
common_test.go:68
↓ 3 callers
Function
saveLists
This function is used to store the main lists into the temporary one for testing
common_test.go:62
↓ 2 callers
Function
createNewArticle
Create a new article with the title and content provided
models.article.go:37
↓ 2 callers
Function
generateSessionToken
()
handlers.user.go:46
↓ 2 callers
Function
getArticleByID
Fetch an article based on the ID supplied
models.article.go:27
↓ 2 callers
Function
getArticlePOSTPayload
()
handlers.article_test.go:312
↓ 1 callers
Function
initializeRoutes
()
routes.go:5
Function
TestArticleAuthenticated
Test that a GET request to an article page returns the article page with the HTTP code 200 for an authenticated user
handlers.article_test.go:105
Function
TestArticleCreationAuthenticated
Test that a POST request to create an article returns an HTTP 200 code along with a success message for an authenticated user
handlers.article_test.go:254
Function
TestArticleCreationPageAuthenticated
Test that a GET request to the article creation page returns the article creation page with the HTTP code 200 for an authenticated user
handlers.article_test.go:200
Function
TestArticleCreationPageUnauthenticated
Test that a GET request to the article creation page returns an HTTP 401 error for an unauthorized user
handlers.article_test.go:237
Function
TestArticleCreationUnauthenticated
Test that a POST request to create an article returns an HTTP 401 error for an unauthorized user
handlers.article_test.go:294
Function
TestArticleListJSON
Test that a GET request to the home page returns the list of articles in JSON format when the Accept header is set to application/json
handlers.article_test.go:142
Function
TestArticleUnauthenticated
Test that a GET request to an article page returns the article page with the HTTP code 200 for an unauthenticated user
handlers.article_test.go:80
Function
TestArticleXML
Test that a GET request to an article page returns the article in XML format when the Accept header is set to application/xml
handlers.article_test.go:171
Function
TestCreateNewArticle
Test the function that creates a new article
models.article_test.go:39
Function
TestEnsureLoggedInAuthenticated
Test the ensureLoggedIn middleware when the user is logged in
middleware.auth_test.go:29
Function
TestEnsureLoggedInUnauthenticated
Test the ensureLoggedIn middleware when the user is not logged in
middleware.auth_test.go:14
Function
TestEnsureNotLoggedInAuthenticated
Test the ensureNotLoggedIn middleware when the user is logged in
middleware.auth_test.go:43
Function
TestEnsureNotLoggedInUnauthenticated
Test the ensureNotLoggedIn middleware when the user is not logged in
middleware.auth_test.go:58
Function
TestGetAllArticles
Test the function that fetches all articles
models.article_test.go:8
Function
TestGetArticleByID
Test the function that fetche an Article by its ID
models.article_test.go:30
Function
TestInvalidUserRegistration
Test that a new user cannot be registered with invalid username/password
models.user_test.go:44
Function
TestLoginAuthenticated
Test that a POST request to the login route returns an HTTP error with code 401 for an authenticated user
handlers.user_test.go:68
Function
TestLoginUnauthenticated
Test that a POST request to login returns a success message for an unauthenticated user
handlers.user_test.go:99
Function
TestLoginUnauthenticatedIncorrectCredentials
Test that a POST request to login returns an error when using incorrect credentials
handlers.user_test.go:134
Function
TestMain
This function is used to do setup before executing the test functions
common_test.go:16
Function
TestRegisterAuthenticated
Test that a POST request to the registration route returns an HTTP error with code 401 for an authenticated user
handlers.user_test.go:212
Function
TestRegisterUnauthenticated
Test that a POST request to register returns a success message for an unauthenticated user
handlers.user_test.go:243
Function
TestRegisterUnauthenticatedUnavailableUsername
Test that a POST request to register returns a an error when the username is already in use
handlers.user_test.go:278
Function
TestSetUserStatusAuthenticated
Test the setUserStatus middleware when the user is logged in
middleware.auth_test.go:72
Function
TestSetUserStatusUnauthenticated
Test the setUserStatus middleware when the user is not logged in
middleware.auth_test.go:98
Function
TestShowIndexPageAuthenticated
Test that a GET request to the home page returns the home page with the HTTP code 200 for an authenticated user
handlers.article_test.go:43
Function
TestShowIndexPageUnauthenticated
Test that a GET request to the home page returns the home page with the HTTP code 200 for an unauthenticated user
handlers.article_test.go:19
Function
TestShowLoginPageAuthenticated
Test that a GET request to the login page returns an HTTP error with code 401 for an authenticated user
handlers.user_test.go:17
Function
TestShowLoginPageUnauthenticated
Test that a GET request to the login page returns the login page with the HTTP code 200 for an unauthenticated user
handlers.user_test.go:45
Function
TestShowRegistrationPageAuthenticated
Test that a GET request to the registration page returns an HTTP error with code 401 for an authenticated user
handlers.user_test.go:161
Function
TestShowRegistrationPageUnauthenticated
Test that a GET request to the registration page returns the registration page with the HTTP code 200 for an unauthenticated user
handlers.user_test.go:189
Function
TestUserValidity
Test the validity of different combinations of username/password
models.user_test.go:8
Function
TestUsernameAvailability
Test the function that checks for username availability
models.user_test.go:65
Function
TestValidUserRegistration
Test if a new user can be registered with valid username/password
models.user_test.go:31
Function
createArticle
(c *gin.Context)
handlers.article.go:49
Function
getArticle
(c *gin.Context)
handlers.article.go:27
Function
logout
(c *gin.Context)
handlers.user.go:53
Function
main
()
main.go:13
Function
performLogin
(c *gin.Context)
handlers.user.go:20
Function
register
(c *gin.Context)
handlers.user.go:70
Function
showArticleCreationPage
(c *gin.Context)
handlers.article.go:21
Function
showIndexPage
(c *gin.Context)
handlers.article.go:12
Function
showLoginPage
(c *gin.Context)
handlers.user.go:13
Function
showRegistrationPage
(c *gin.Context)
handlers.user.go:64