| 115 | } |
| 116 | |
| 117 | func (s *Server) metadataAnnotator() func(ctx context.Context, req *http.Request) metadata.MD { |
| 118 | return func(ctx context.Context, req *http.Request) metadata.MD { |
| 119 | md := metadata.New(map[string]string{}) |
| 120 | |
| 121 | cookie, err := req.Cookie("token") |
| 122 | if err == nil { |
| 123 | metadatautil.SetAuthToken(md, cookie.Value) |
| 124 | } |
| 125 | |
| 126 | authHeader := req.Header.Get("Authorization") |
| 127 | if strings.HasPrefix(authHeader, "Bearer ") { |
| 128 | token := strings.TrimPrefix(authHeader, "Bearer ") |
| 129 | metadatautil.SetAuthToken(md, token) |
| 130 | } |
| 131 | |
| 132 | return md |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | func (s *Server) forwardResponseOption() func(ctx context.Context, w http.ResponseWriter, msg proto.Message) error { |
| 137 | return func(ctx context.Context, w http.ResponseWriter, msg proto.Message) error { |