Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List the handlers on startup #1131

Closed
wants to merge 18 commits into from
Closed

List the handlers on startup #1131

wants to merge 18 commits into from

Conversation

jithinjk
Copy link

@jithinjk jithinjk commented Oct 17, 2017

Fairly new to this community. Not sure if this counts as a feature.
capture

  • List route handlers at startup,
  • Also, number of handlers running.

Would be nice to have this to get better understanding of handlers running.

Sorry for multiple commit builds, new to travis-ci.

@codecov
Copy link

codecov bot commented Oct 17, 2017

Codecov Report

Merging #1131 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1131      +/-   ##
==========================================
+ Coverage    98.4%   98.42%   +0.02%     
==========================================
  Files          34       34              
  Lines        1757     1781      +24     
==========================================
+ Hits         1729     1753      +24     
  Misses         23       23              
  Partials        5        5
Impacted Files Coverage Δ
debug.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 783c7ee...a076bf3. Read the comment docs.

@thinkerou
Copy link
Member

Maybe you should squash commits.

.travis.yml Outdated
@@ -11,6 +11,7 @@ git:
depth: 3

install:
- go get golang.org/x/crypto/ssh/terminal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use govendor in Makefile?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix these issues

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the Makefile. Can you pls validate now.

List the handlers during start-up

List the handlers during start-up

Testing travis - 1

Testing travis - 2

Testing travis - 3

Testing travis - 4

Fixed travis build issues and test case validation errors

Odd/Even route listing testcase added

Fix for travis fail - 688972b

test for getTerminalSize
@appleboy
Copy link
Member

@jithinjk Can you post the screenshots?

@jithinjk
Copy link
Author

Attached screenshot. Capture

@thinkerou
Copy link
Member

thinkerou commented Feb 26, 2019

#1729 has added HandlerNames() method, the pr have any worth? thanks! I think we should close the pr, thanks!

@appleboy
Copy link
Member

conflicts.

@thinkerou
Copy link
Member

thinkerou commented Mar 1, 2019

@appleboy we still need the pull request? I think we should not use it, because it will depend on one package, the pull request have not clear useful, and we have had HandlerNames method. thanks!

@appleboy
Copy link
Member

appleboy commented Mar 1, 2019

this should be pending now?

@thinkerou
Copy link
Member

closing

@hyson007
Copy link

hyson007 commented Jul 7, 2022

hi,

I couldn't find anywhere mention about this, I'm new to Gin and couldn't figure out why go-gin think there are 3 handlers when I only have one function passed into the POST func?

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] POST /accounts  --> github.com/hyson007/simpleBank/api.(*Server).createAccount-fm (3 handlers) 
^^^^ in above line ^^^^



func NewServer(store *db.Store) *Server {
	server := &Server{store: store}
	router := gin.Default()
	server.router = router

	router.POST("/accounts", server.createAccount)

	return server
}

func (s *Server) Start(addr string) error {
	return s.router.Run(addr)
}

func (s *Server) createAccount(ctx *gin.Context) {
	var req createAccountRequest
	if err := ctx.ShouldBindJSON(&req); err != nil {
		ctx.JSON(http.StatusBadRequest, errorResponse(err))
		return
	}

	arg := db.CreateAccountParams{
		Owner:    req.Owner,
		Currency: req.Currency,
		Balance:  0,
	}

	account, err := s.store.CreateAccount(ctx, arg)
	if err != nil {
		ctx.JSON(http.StatusInternalServerError, errorResponse(err))
		return
	}

	ctx.JSON(http.StatusOK, account)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants