-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
60 lines (54 loc) · 1.05 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package goapi
import (
"context"
"crypto"
"github.com/gin-gonic/gin"
"log"
"time"
)
/*@API*/
type ASimpleReq struct {
Data string
}
/*@API*/
type ASimpleRes struct {
Data string
}
/*@API*/
type AComplexReq struct {
Country string
City string
HouseNumber int64
IsCondo bool
SomeWeirdTest string `json:"SUPERCALIFRAGILISPEALIDOUX"`
Recursive map[string]AComplexReq
Arrofpstr []string `json:"arrofpstr,omitempty"`
When time.Time
Some crypto.Decrypter
}
/*
@API
@PATH: /someapi
@PERM: ASD
@VERB: POST
*/
func ApiMethod01(ctx context.Context, s *ASimpleReq) (out *ASimpleRes, err error) {
log.Printf("Got: %#v", s)
out = &ASimpleRes{}
out.Data = time.Now().String() + " - Hey Ya!"
return
}
/*
@API
@PATH: /someapi2
@PERM: ASD
@VERB: GET
*/
func ApiMethod02(ctx context.Context, s *AComplexReq) (out *ASimpleRes, err error) {
gctx := ctx.Value("CTX").(*gin.Context)
log.Printf(gctx.FullPath())
print("Got:" + s.SomeWeirdTest)
out = &ASimpleRes{}
out.Data = time.Now().String() + " - Hey Ya!"
return
}