@@ -4,21 +4,26 @@ import (
4
4
"net/http"
5
5
"github.com/gin-gonic/gin"
6
6
)
7
- func PostMethod (c * gin.Context ) {
8
- fmt .Println ("\n api.go 'PostMethod' called" )
9
- message := "PostMethod called"
10
- c .JSON (http .StatusOK , message )
11
- }
12
7
func GetMethod (c * gin.Context ) {
13
- fmt .Println ("\n api.go 'GetMethod' called" )
14
- message := "GetMethod called"
8
+ fmt .Println ("\n 'GetMethod' called" )
9
+ IdValue := c .Params .ByName ("IdValue" )
10
+ message := "GetMethod Called With Param: " + IdValue
15
11
c .JSON (http .StatusOK , message )
12
+ ReqPayload := make ([]byte , 1024 )
13
+ ReqPayload , err := c .GetRawData ()
14
+ if err != nil {
15
+ fmt .Println (err )
16
+ return
17
+ }
18
+ fmt .Println ("Request Payload Data: " , string (ReqPayload ))
16
19
}
17
20
func main () {
18
21
router := gin .Default ()
22
+ subRouterAuthenticated := router .Group ("/api/v1/PersonId" , gin .BasicAuth (gin.Accounts {
23
+ "admin" : "adminpass" ,
24
+ }))
25
+ subRouterAuthenticated .GET ("/:IdValue" , GetMethod )
26
+ listenPort := "1357"
19
27
20
- router .POST ("/" , PostMethod )
21
- router .GET ("/" , GetMethod )
22
- listenPort := "4000"
23
- router .Run (":" + listenPort )
28
+ router .Run (":" + listenPort )
24
29
}
0 commit comments