Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add metadata or header ? #51

Open
technomaniac opened this issue Sep 5, 2018 · 12 comments
Open

How to add metadata or header ? #51

technomaniac opened this issue Sep 5, 2018 · 12 comments

Comments

@technomaniac
Copy link

No description provided.

@awalterschulze
Copy link
Member

@scbizu
Copy link
Contributor

scbizu commented Dec 20, 2018

Hi @awalterschulze , I read the CreateCustom in form.go,and still have some questions. When we setup context metadata/header in grpc context , we will not define these kind of fields explicitly.

In my way, I will prefer to add an additional field(say as context),this field name and value is also customized, the fake code will look like this:

	contextString := req.FormValue("context")
	contextStringMap := make(map[string]string)
	if len(contextString) > 0 {
		err := encoding_json.Unmarshal([]byte(contextString), &contextStringMap)
		if err != nil {
			if err != io.EOF {
				w.Write([]byte("<div class=\"alert alert-danger\" role=\"alert\">" + err.Error() + "</div>"))
				return
			}
			w.Write([]byte("<div class=\"alert alert-danger\" role=\"alert\">" + err.Error() + "</div>"))
		}
	}
	w.Write([]byte(FormClient_RPCXXXXXX))
	if !someValue {
		w.Write([]byte(Footer))
		return
	}
	for metaKey, metaValue := range contextStringMap {
              // do some meta match here
        }

@awalterschulze
Copy link
Member

awalterschulze commented Dec 20, 2018 via email

@scbizu
Copy link
Contributor

scbizu commented Dec 21, 2018

Haha , you can check the grpc-go's oauth example for the grpc context metadata.

@awalterschulze
Copy link
Member

awalterschulze commented Dec 21, 2018 via email

@scbizu
Copy link
Contributor

scbizu commented Dec 21, 2018

we will use this kind of data for auth and trace and other middleware operations

@awalterschulze
Copy link
Member

awalterschulze commented Dec 21, 2018 via email

@scbizu
Copy link
Contributor

scbizu commented Dec 22, 2018

Read it as input

@awalterschulze
Copy link
Member

awalterschulze commented Dec 22, 2018 via email

@scbizu
Copy link
Contributor

scbizu commented Dec 22, 2018

yep, so I fork another letmegrpc to our private repo, and will do some special edition XD

@awalterschulze
Copy link
Member

awalterschulze commented Dec 22, 2018 via email

@scbizu
Copy link
Contributor

scbizu commented Dec 23, 2018

aha still WIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants