MCPcopy Create free account

hub / github.com/demo-apps/go-gin-app / functions

Functions65 in github.com/demo-apps/go-gin-app

↓ 26 callersFunctiongetRouter
Helper function to create a router during testing
common_test.go:25
↓ 16 callersFunctionensureNotLoggedIn
This middleware ensures that a request will be aborted with an error if the user is already logged in
middleware.auth.go:28
↓ 9 callersFunctionensureLoggedIn
This middleware ensures that a request will be aborted with an error if the user is not logged in
middleware.auth.go:13
↓ 9 callersFunctiontestHTTPResponse
Helper function to process a request and test its response
common_test.go:35
↓ 8 callersFunctionrender
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 callersFunctionisUserValid
Check if the username and password combination is valid
models.user.go:28
↓ 5 callersFunctionregisterNewUser
Register a new user with the given username and password NOTE: For this demo, we
models.user.go:39
↓ 4 callersFunctiongetAllArticles
Return a list of all the articles
models.article.go:22
↓ 4 callersFunctionisUsernameAvailable
Check if the supplied username is available
models.user.go:54
↓ 4 callersFunctionsetLoggedIn
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 callersFunctionsetUserStatus
This middleware sets whether the user is logged in or not
middleware.auth.go:42
↓ 4 callersFunctiontestMiddlewareRequest
This is a helper function that allows us to reuse some code in the above test methods
common_test.go:50
↓ 3 callersFunctiongetLoginPOSTPayload
()
handlers.user_test.go:303
↓ 3 callersFunctiongetRegistrationPOSTPayload
()
handlers.user_test.go:311
↓ 3 callersFunctionrestoreLists
This function is used to restore the main lists from the temporary one
common_test.go:68
↓ 3 callersFunctionsaveLists
This function is used to store the main lists into the temporary one for testing
common_test.go:62
↓ 2 callersFunctioncreateNewArticle
Create a new article with the title and content provided
models.article.go:37
↓ 2 callersFunctiongenerateSessionToken
()
handlers.user.go:46
↓ 2 callersFunctiongetArticleByID
Fetch an article based on the ID supplied
models.article.go:27
↓ 2 callersFunctiongetArticlePOSTPayload
()
handlers.article_test.go:312
↓ 1 callersFunctioninitializeRoutes
()
routes.go:5
FunctionTestArticleAuthenticated
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
FunctionTestArticleCreationAuthenticated
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
FunctionTestArticleCreationPageAuthenticated
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
FunctionTestArticleCreationPageUnauthenticated
Test that a GET request to the article creation page returns an HTTP 401 error for an unauthorized user
handlers.article_test.go:237
FunctionTestArticleCreationUnauthenticated
Test that a POST request to create an article returns an HTTP 401 error for an unauthorized user
handlers.article_test.go:294
FunctionTestArticleListJSON
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
FunctionTestArticleUnauthenticated
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
FunctionTestArticleXML
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
FunctionTestCreateNewArticle
Test the function that creates a new article
models.article_test.go:39
FunctionTestEnsureLoggedInAuthenticated
Test the ensureLoggedIn middleware when the user is logged in
middleware.auth_test.go:29
FunctionTestEnsureLoggedInUnauthenticated
Test the ensureLoggedIn middleware when the user is not logged in
middleware.auth_test.go:14
FunctionTestEnsureNotLoggedInAuthenticated
Test the ensureNotLoggedIn middleware when the user is logged in
middleware.auth_test.go:43
FunctionTestEnsureNotLoggedInUnauthenticated
Test the ensureNotLoggedIn middleware when the user is not logged in
middleware.auth_test.go:58
FunctionTestGetAllArticles
Test the function that fetches all articles
models.article_test.go:8
FunctionTestGetArticleByID
Test the function that fetche an Article by its ID
models.article_test.go:30
FunctionTestInvalidUserRegistration
Test that a new user cannot be registered with invalid username/password
models.user_test.go:44
FunctionTestLoginAuthenticated
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
FunctionTestLoginUnauthenticated
Test that a POST request to login returns a success message for an unauthenticated user
handlers.user_test.go:99
FunctionTestLoginUnauthenticatedIncorrectCredentials
Test that a POST request to login returns an error when using incorrect credentials
handlers.user_test.go:134
FunctionTestMain
This function is used to do setup before executing the test functions
common_test.go:16
FunctionTestRegisterAuthenticated
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
FunctionTestRegisterUnauthenticated
Test that a POST request to register returns a success message for an unauthenticated user
handlers.user_test.go:243
FunctionTestRegisterUnauthenticatedUnavailableUsername
Test that a POST request to register returns a an error when the username is already in use
handlers.user_test.go:278
FunctionTestSetUserStatusAuthenticated
Test the setUserStatus middleware when the user is logged in
middleware.auth_test.go:72
FunctionTestSetUserStatusUnauthenticated
Test the setUserStatus middleware when the user is not logged in
middleware.auth_test.go:98
FunctionTestShowIndexPageAuthenticated
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
FunctionTestShowIndexPageUnauthenticated
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
FunctionTestShowLoginPageAuthenticated
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
FunctionTestShowLoginPageUnauthenticated
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
FunctionTestShowRegistrationPageAuthenticated
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
FunctionTestShowRegistrationPageUnauthenticated
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
FunctionTestUserValidity
Test the validity of different combinations of username/password
models.user_test.go:8
FunctionTestUsernameAvailability
Test the function that checks for username availability
models.user_test.go:65
FunctionTestValidUserRegistration
Test if a new user can be registered with valid username/password
models.user_test.go:31
FunctioncreateArticle
(c *gin.Context)
handlers.article.go:49
FunctiongetArticle
(c *gin.Context)
handlers.article.go:27
Functionlogout
(c *gin.Context)
handlers.user.go:53
Functionmain
()
main.go:13
FunctionperformLogin
(c *gin.Context)
handlers.user.go:20
Functionregister
(c *gin.Context)
handlers.user.go:70
FunctionshowArticleCreationPage
(c *gin.Context)
handlers.article.go:21
FunctionshowIndexPage
(c *gin.Context)
handlers.article.go:12
FunctionshowLoginPage
(c *gin.Context)
handlers.user.go:13
FunctionshowRegistrationPage
(c *gin.Context)
handlers.user.go:64