Click here to Skip to main content
15,945,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new in gin golang,
i want to develop api for get course .
but i have a problem in routes.go

when i put this

func Routes(host string) {
	var router = gin.Default()
	router.Use(_c.CORSMiddleware())
	router.Use(_c.RequestHeaderMiddleware)
	router.GET("/grade/courseid:courseid", ggc.GetGradesbyCourseID)
	router.GET("/gradegrades:userid&courseid", ggc.GetDatabyUserID)

	router.Run(host)
}

i can't hit api from postman ,the responses is '404 not found'

but if i use this

<pre>
func Routes(host string) {
	var router = gin.Default()
	router.Use(_c.CORSMiddleware())
	router.Use(_c.RequestHeaderMiddleware)
	router.GET("/grade/courseid:courseid", ggc.GetGradesbyCourseID)
	//router.GET("/gradegrades:userid&courseid", ggc.GetDatabyUserID)

	router.Run(host)
}


it can call it from post man

What I have tried:

is anyone can help me? i wish someone can help me
Posted
Updated 12-Feb-23 23:48pm

1 solution

Replace the '&' with '/' as per multiple parameters

router.GET("/gradegrades:userid/courseid", ggc.GetDatabyUserID)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900