Comments (4)
i got it
from go-pdk.
@yaobo-lab
How did you solve this?
Getting and setting the cookie.
from go-pdk.
Hi @yaobo-lab,
I have the same question. Can you share your solution with us?
from go-pdk.
I found a solution:
func (config Config) Access(kong *pdk.PDK) {
cookieHeader, _ := kong.Request.GetHeader("cookie")
cookies := getCookies(cookieHeader)
tmp, _ := json.MarshalIndent(cookies, "", " ")
kong.Log.Info(fmt.Sprintf("Cookies hehehehe :%v", string(tmp)))
}
// You can return as []*Cookies if you want
func getCookies(cookieHeaderValue string) map[string]string {
if cookieHeaderValue == "" {
return map[string]string{}
}
header := http.Header{}
header.Add("Cookie", cookieHeaderValue)
request := http.Request{Header: header}
rs := map[string]string{}
for _, c := range request.Cookies() {
rs[c.Name] = c.Value
}
return rs
}
from go-pdk.
Related Issues (20)
- SetUpstream fail with error "bad argument #2 to 'encode' (table expected, got boolean)"
- panic: `kong.Request.GetQueryArg` using test module
- Impossible to access kong.Router.GetService() from Log phase. HOT 1
- Test package errors when using kong.Response.ExitStatus
- Possible error loss in the pbserver.servePb HOT 1
- Support for `kong.log.set_serialize_value` HOT 1
- Test package only supports `GET` requests HOT 5
- ExitArgs.Body should be `[]byte` instead of `string` HOT 2
- Kong version support HOT 1
- rewrite ngx.var HOT 1
- Can we handle tls termination during certificate phase using kong golang pdk HOT 2
- How can I print log to log_file? HOT 11
- Unable to set path in access phase using kong.service.request.set_path HOT 1
- `kong.Request.GetHeaders` returns headers uppercased in test module HOT 2
- kong.ServiceResponse.GetRawBody() return empty string HOT 2
- feature-request: Support Tracing PDK APIs HOT 3
- Tag v_0.8.0 can't access kong.service.request.enable_buffering (method not found) HOT 1
- [Questions] How to add description or comments, and validation, default value, etc. HOT 1
- socket failed: No such file or directory HOT 9
- kong.client.authenticate should support nil values for consumer and credential HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-pdk.