forked from gofr-dev/gofr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest_gofr.go
63 lines (49 loc) · 1.13 KB
/
request_gofr.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
61
62
63
// Code generated by gofr.dev/cli/gofr. DO NOT EDIT.
// versions:
// gofr-cli v0.6.0
// gofr.dev v1.37.0
// source: hello.proto
package server
import (
"context"
"fmt"
"reflect"
)
// Request Wrappers
type HelloRequestWrapper struct {
ctx context.Context
*HelloRequest
}
func (h *HelloRequestWrapper) Context() context.Context {
return h.ctx
}
func (h *HelloRequestWrapper) Param(s string) string {
return ""
}
func (h *HelloRequestWrapper) PathParam(s string) string {
return ""
}
func (h *HelloRequestWrapper) Bind(p interface{}) error {
ptr := reflect.ValueOf(p)
if ptr.Kind() != reflect.Ptr {
return fmt.Errorf("expected a pointer, got %T", p)
}
hValue := reflect.ValueOf(h.HelloRequest).Elem()
ptrValue := ptr.Elem()
for i := 0; i < hValue.NumField(); i++ {
field := hValue.Type().Field(i)
if field.Name == "state" || field.Name == "sizeCache" || field.Name == "unknownFields" {
continue
}
if field.IsExported() {
ptrValue.Field(i).Set(hValue.Field(i))
}
}
return nil
}
func (h *HelloRequestWrapper) HostName() string {
return ""
}
func (h *HelloRequestWrapper) Params(s string) []string {
return nil
}