Commit 36ab7ddd authored by Felipe Andrade's avatar Felipe Andrade

replace base64 encoding for params with sha256 hash

parent 2745b6cc
...@@ -2,8 +2,9 @@ package proxyd ...@@ -2,8 +2,9 @@ package proxyd
import ( import (
"context" "context"
"encoding/base64" "crypto/sha256"
"encoding/json" "encoding/json"
"fmt"
"strings" "strings"
"sync" "sync"
...@@ -21,8 +22,10 @@ type StaticMethodHandler struct { ...@@ -21,8 +22,10 @@ type StaticMethodHandler struct {
} }
func (e *StaticMethodHandler) key(req *RPCReq) string { func (e *StaticMethodHandler) key(req *RPCReq) string {
// signature is a cache-friendly base64-encoded string with json.RawMessage param contents // signature is the hashed json.RawMessage param contents
signature := base64.StdEncoding.EncodeToString(req.Params) h := sha256.New()
h.Write(req.Params)
signature := fmt.Sprintf("%x", h.Sum(nil))
return strings.Join([]string{"cache", req.Method, signature}, ":") return strings.Join([]string{"cache", req.Method, signature}, ":")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment