this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more work on lexgen, can mostly generate server stubs now

why 1246dab9 47fb45d6

+101 -26
+5 -1
api/extra.go
··· 6 6 "net/url" 7 7 8 8 did "github.com/whyrusleeping/go-did" 9 + otel "go.opentelemetry.io/otel" 9 10 ) 10 11 11 12 func ResolveDidToHandle(ctx context.Context, atp *ATProto, pls *PLCServer, udid string) (string, string, error) { 12 - doc, err := pls.GetDocument(udid) 13 + ctx, span := otel.Tracer("gosky").Start(ctx, "resolveDidToHandle") 14 + defer span.End() 15 + 16 + doc, err := pls.GetDocument(ctx, udid) 13 17 if err != nil { 14 18 return "", "", err 15 19 }
+7 -2
api/plc.go
··· 1 1 package api 2 2 3 3 import ( 4 + "context" 4 5 "encoding/json" 5 6 "fmt" 6 7 "net/http" 7 8 8 9 did "github.com/whyrusleeping/go-did" 10 + otel "go.opentelemetry.io/otel" 9 11 ) 10 12 11 13 type PLCServer struct { ··· 13 15 C *http.Client 14 16 } 15 17 16 - func (s *PLCServer) GetDocument(didstr string) (*did.Document, error) { 18 + func (s *PLCServer) GetDocument(ctx context.Context, didstr string) (*did.Document, error) { 19 + ctx, span := otel.Tracer("gosky").Start(ctx, "plsResolveDid") 20 + defer span.End() 21 + 17 22 if s.C == nil { 18 23 s.C = http.DefaultClient 19 24 } ··· 23 28 return nil, err 24 29 } 25 30 26 - resp, err := s.C.Do(req) 31 + resp, err := s.C.Do(req.WithContext(ctx)) 27 32 if err != nil { 28 33 return nil, err 29 34 }
+11 -1
go.mod
··· 4 4 5 5 require ( 6 6 github.com/ipfs/go-block-format v0.0.3 7 + github.com/ipfs/go-bs-sqlite3 v0.0.0-20221122195556-bfcee1be620d 7 8 github.com/ipfs/go-car v0.0.4 8 9 github.com/ipfs/go-cid v0.1.0 9 10 github.com/ipfs/go-datastore v0.5.1 ··· 13 14 github.com/ipfs/go-ipld-format v0.3.0 14 15 github.com/ipld/go-car v0.5.0 15 16 github.com/ipld/go-car/v2 v2.5.1 17 + github.com/labstack/echo/v4 v4.7.2 16 18 github.com/multiformats/go-multihash v0.1.0 17 19 github.com/urfave/cli/v2 v2.23.0 18 20 github.com/whyrusleeping/cbor-gen v0.0.0-20221120232258-33755d0abe95 19 21 github.com/whyrusleeping/go-did v0.0.0-20221105001742-8d9e0ffb0d59 22 + go.opentelemetry.io/otel v0.20.0 20 23 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 21 24 gorm.io/driver/sqlite v1.4.3 22 25 gorm.io/gorm v1.24.1 ··· 32 35 github.com/hashicorp/golang-lru v0.5.4 // indirect 33 36 github.com/ipfs/bbloom v0.0.4 // indirect 34 37 github.com/ipfs/go-blockservice v0.3.0 // indirect 35 - github.com/ipfs/go-bs-sqlite3 v0.0.0-20221122195556-bfcee1be620d // indirect 36 38 github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect 37 39 github.com/ipfs/go-ipfs-exchange-interface v0.1.0 // indirect 38 40 github.com/ipfs/go-ipfs-util v0.0.2 // indirect ··· 48 50 github.com/jinzhu/inflection v1.0.0 // indirect 49 51 github.com/jinzhu/now v1.1.5 // indirect 50 52 github.com/klauspost/cpuid/v2 v2.0.9 // indirect 53 + github.com/labstack/gommon v0.3.1 // indirect 51 54 github.com/lestrrat-go/blackmagic v1.0.1 // indirect 52 55 github.com/lestrrat-go/httpcc v1.0.1 // indirect 53 56 github.com/lestrrat-go/httprc v1.0.1 // indirect 54 57 github.com/lestrrat-go/iter v1.0.2 // indirect 55 58 github.com/lestrrat-go/jwx/v2 v2.0.0 // indirect 56 59 github.com/lestrrat-go/option v1.0.0 // indirect 60 + github.com/mattn/go-colorable v0.1.11 // indirect 57 61 github.com/mattn/go-isatty v0.0.14 // indirect 58 62 github.com/mattn/go-sqlite3 v1.14.15 // indirect 59 63 github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect ··· 68 72 github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect 69 73 github.com/russross/blackfriday/v2 v2.1.0 // indirect 70 74 github.com/spaolacci/murmur3 v1.1.0 // indirect 75 + github.com/valyala/bytebufferpool v1.0.0 // indirect 76 + github.com/valyala/fasttemplate v1.2.1 // indirect 71 77 github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect 78 + go.opentelemetry.io/otel/metric v0.20.0 // indirect 79 + go.opentelemetry.io/otel/trace v0.20.0 // indirect 72 80 go.uber.org/atomic v1.7.0 // indirect 73 81 go.uber.org/multierr v1.7.0 // indirect 74 82 go.uber.org/zap v1.16.0 // indirect 75 83 golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect 76 84 golang.org/x/exp v0.0.0-20210615023648-acb5c1269671 // indirect 85 + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect 77 86 golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect 87 + golang.org/x/text v0.3.7 // indirect 78 88 google.golang.org/protobuf v1.27.1 // indirect 79 89 lukechampine.com/blake3 v1.1.6 // indirect 80 90 )
+20 -2
go.sum
··· 264 264 github.com/ipfs/go-blockservice v0.1.0/go.mod h1:hzmMScl1kXHg3M2BjTymbVPjv627N7sYcvYaKbop39M= 265 265 github.com/ipfs/go-blockservice v0.3.0 h1:cDgcZ+0P0Ih3sl8+qjFr2sVaMdysg/YZpLj5WJ8kiiw= 266 266 github.com/ipfs/go-blockservice v0.3.0/go.mod h1:P5ppi8IHDC7O+pA0AlGTF09jruB2h+oP3wVVaZl8sfk= 267 - github.com/ipfs/go-bs-sqlite3 v0.0.0-20220831203040-60c689e583c7 h1:fz87EjHgBPCs3+VIBz05HhRxJE3dmBq9SRZLSfB8QFI= 268 - github.com/ipfs/go-bs-sqlite3 v0.0.0-20220831203040-60c689e583c7/go.mod h1:teLHjK8IzDTwi0P/01GMsruXAYRediT8hY4ABcsusag= 269 267 github.com/ipfs/go-bs-sqlite3 v0.0.0-20221122195556-bfcee1be620d h1:9V+GGXCuOfDiFpdAHz58q9mKLg447xp0cQKvqQrAwYE= 270 268 github.com/ipfs/go-bs-sqlite3 v0.0.0-20221122195556-bfcee1be620d/go.mod h1:pMbnFyNAGjryYCLCe59YDLRv/ujdN+zGJBT1umlvYRM= 271 269 github.com/ipfs/go-car v0.0.4 h1:zLhxykvk4SFU4oIpgcIoiolVL3jqcK0hjqcQfUSs4dk= ··· 436 434 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 437 435 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 438 436 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 437 + github.com/labstack/echo/v4 v4.7.2 h1:Kv2/p8OaQ+M6Ex4eGimg9b9e6icoxA42JSlOR3msKtI= 438 + github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= 439 + github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= 440 + github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= 439 441 github.com/lestrrat-go/blackmagic v1.0.1 h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80= 440 442 github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= 441 443 github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= ··· 642 644 github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 643 645 github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= 644 646 github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 647 + github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= 648 + github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= 645 649 github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 646 650 github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 647 651 github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= ··· 919 923 github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 920 924 github.com/urfave/cli/v2 v2.23.0 h1:pkly7gKIeYv3olPAeNajNpLjeJrmTPYCoZWaV+2VfvE= 921 925 github.com/urfave/cli/v2 v2.23.0/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= 926 + github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 927 + github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 928 + github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= 929 + github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= 922 930 github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= 923 931 github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= 924 932 github.com/warpfork/go-testmark v0.3.0 h1:Q81c4u7hT+BR5kNfNQhEF0VT2pmL7+Kk0wD+ORYl7iA= ··· 960 968 go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 961 969 go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 962 970 go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= 971 + go.opentelemetry.io/otel v0.20.0 h1:eaP0Fqu7SXHwvjiqDq83zImeehOHX8doTvU9AwXON8g= 972 + go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= 973 + go.opentelemetry.io/otel/metric v0.20.0 h1:4kzhXFP+btKm4jwxpjIqjs41A7MakRFUS86bqLHTIw8= 974 + go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= 975 + go.opentelemetry.io/otel/oteltest v0.20.0 h1:HiITxCawalo5vQzdHfKeZurV8x7ljcqAgiWzF6Vaeaw= 976 + go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= 977 + go.opentelemetry.io/otel/trace v0.20.0 h1:1DL6EXUdcg95gukhuRRvLDO/4X5THh/5dIV52lqtnbw= 978 + go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= 963 979 go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 964 980 go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 965 981 go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= ··· 1126 1142 golang.org/x/sys v0.0.0-20210426080607-c94f62235c83/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 1127 1143 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 1128 1144 golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 1145 + golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 1129 1146 golang.org/x/sys v0.0.0-20211103235746-7861aae1554b h1:1VkfZQv42XQlA/jchYumAnv1UPo6RgF9rJFkTgZIxO4= 1130 1147 golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 1131 1148 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= ··· 1137 1154 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 1138 1155 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 1139 1156 golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= 1157 + golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 1140 1158 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 1141 1159 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 1142 1160 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+54 -16
lex/gen.go
··· 14 14 "strings" 15 15 ) 16 16 17 + const ( 18 + EncodingCBOR = "application/cbor" 19 + EncodingJSON = "application/json" 20 + ) 21 + 17 22 type Schema struct { 18 23 prefix string 19 24 ··· 243 248 244 249 params := "ctx context.Context, c *xrpc.Client" 245 250 inpvar := "nil" 251 + inpenc := "" 246 252 if s.Input != nil { 247 - params = fmt.Sprintf("%s, input %s_Input", params, fname) 248 253 inpvar = "input" 254 + inpenc = s.Input.Encoding 255 + switch s.Input.Encoding { 256 + case EncodingCBOR: 257 + params = fmt.Sprintf("%s, input io.Reader", params) 258 + case EncodingJSON: 259 + params = fmt.Sprintf("%s, input %s_Input", params, fname) 260 + default: 261 + return fmt.Errorf("unsupported input encoding: %q", s.Input.Encoding) 262 + } 249 263 } 250 264 251 265 if s.Parameters != nil { ··· 265 279 266 280 out := "error" 267 281 if s.Output != nil { 268 - out = fmt.Sprintf("(*%s_Output, error)", fname) 282 + switch s.Output.Encoding { 283 + case EncodingCBOR: 284 + out = "([]byte, error)" 285 + case EncodingJSON: 286 + out = fmt.Sprintf("(*%s_Output, error)", fname) 287 + default: 288 + return fmt.Errorf("unrecognized encoding scheme: %q", s.Output.Encoding) 289 + } 269 290 } 270 291 271 292 fmt.Fprintf(w, "func %s(%s) %s {\n", fname, params, out) ··· 274 295 errRet := "err" 275 296 outRet := "nil" 276 297 if s.Output != nil { 277 - fmt.Fprintf(w, "\tvar out %s_Output\n", fname) 278 - outvar = "&out" 279 - errRet = "nil, err" 280 - outRet = "&out, nil" 298 + switch s.Output.Encoding { 299 + case EncodingCBOR: 300 + fmt.Fprintf(w, "buf := new(bytes.Buffer)\n") 301 + outvar = "buf" 302 + errRet = "nil, err" 303 + outRet = "buf.Bytes(), nil" 304 + 305 + case EncodingJSON: 306 + fmt.Fprintf(w, "\tvar out %s_Output\n", fname) 307 + outvar = "&out" 308 + errRet = "nil, err" 309 + outRet = "&out, nil" 310 + default: 311 + return fmt.Errorf("unrecognized output encoding: %q", s.Output.Encoding) 312 + } 281 313 } 282 314 283 315 queryparams := "nil" ··· 306 338 return fmt.Errorf("can only generate RPC for Query or Procedure (got %s)", s.Type) 307 339 } 308 340 309 - fmt.Fprintf(w, "\tif err := c.Do(ctx, %s, \"%s\", %s, %s, %s); err != nil {\n", reqtype, s.ID, queryparams, inpvar, outvar) 341 + fmt.Fprintf(w, "\tif err := c.Do(ctx, %s, %q, \"%s\", %s, %s, %s); err != nil {\n", reqtype, inpenc, s.ID, queryparams, inpvar, outvar) 310 342 fmt.Fprintf(w, "\t\treturn %s\n", errRet) 311 343 fmt.Fprintf(w, "\t}\n\n") 312 344 fmt.Fprintf(w, "\treturn %s\n", outRet) ··· 370 402 continue 371 403 } 372 404 373 - fmt.Fprintf(w, "e.%s(\"/xrpc/%s\", s.%s)\n", verb, s.ID, idToTitle(s.ID)) 405 + fmt.Fprintf(w, "e.%s(\"/xrpc/%s\", s.Handle%s)\n", verb, s.ID, idToTitle(s.ID)) 374 406 } 375 407 376 408 fmt.Fprintf(w, "return nil\n}\n\n") ··· 408 440 tname := s.nameFromID(s.ID, prefix) 409 441 410 442 fmt.Fprintf(w, "func (s *Server) Handle%s(c echo.Context) error {\n", fname) 443 + 444 + fmt.Fprintf(w, "ctx, span := otel.Tracer(\"server\").Start(c.Request().Context(), %q)\n", "Handle"+fname) 445 + fmt.Fprintf(w, "defer span.End()\n") 446 + 447 + impname := importNameForPrefix(prefix) 411 448 412 449 paramtypes := []string{"ctx context.Context"} 413 450 params := []string{"ctx"} ··· 436 473 } 437 474 } else if s.Type == "procedure" { 438 475 fmt.Fprintf(w, ` 439 - var body types.%s 440 - if err := e.Bind(&out); err != nil { 476 + var body %s.%s 477 + if err := c.Bind(&body); err != nil { 441 478 return err 442 479 } 443 - `, tname+"_Input") 480 + `, impname, tname+"_Input") 444 481 } else { 445 482 return fmt.Errorf("can only generate handlers for queries or procedures") 446 483 } 447 484 448 - assign := "err" 485 + assign := "handleErr" 449 486 returndef := "error" 450 487 if s.Output != nil { 451 - assign = "out, err" 452 - fmt.Fprintf(w, "var out types.%s\n", tname+"_Output") 453 - returndef = fmt.Sprintf("(*types.%s_Output, error)", tname) 488 + assign = "out, handleErr" 489 + fmt.Fprintf(w, "var out %s.%s\n", impname, tname+"_Output") 490 + returndef = fmt.Sprintf("(*%s.%s_Output, error)", impname, tname) 454 491 } 455 - fmt.Fprintf(w, "var err error\n") 492 + fmt.Fprintf(w, "var handleErr error\n") 456 493 fmt.Fprintf(w, "// func (s *Server) handle%s(%s) %s\n", fname, strings.Join(paramtypes, ","), returndef) 457 494 fmt.Fprintf(w, "%s = s.handle%s(%s)\n", assign, fname, strings.Join(params, ",")) 495 + fmt.Fprintf(w, "if handleErr != nil {\nreturn handleErr\n}\n") 458 496 459 497 fmt.Fprintf(w, "return nil // TODO: implement me\n}\n\n") 460 498
+1 -1
mst/mst_test.go
··· 56 56 fmt.Println(ncid) 57 57 } 58 58 59 - func TestEdgeCase9(t *testing.T) { 59 + func TestEdgeCase(t *testing.T) { 60 60 m := map[string]string{ 61 61 "97206d5e4a18/19fbf0b79789/1710133f2dd6": "cats", 62 62 }
+3 -3
xrpc/xrpc.go
··· 47 47 return strings.Join(parts, "&") 48 48 } 49 49 50 - func (c *Client) Do(ctx context.Context, kind XRPCRequestType, method string, params map[string]interface{}, bodyobj interface{}, out interface{}) error { 50 + func (c *Client) Do(ctx context.Context, kind XRPCRequestType, inpenc string, method string, params map[string]interface{}, bodyobj interface{}, out interface{}) error { 51 51 var body io.Reader 52 52 if bodyobj != nil { 53 53 if rr, ok := bodyobj.(io.Reader); ok { ··· 82 82 return err 83 83 } 84 84 85 - if bodyobj != nil { 86 - req.Header.Set("Content-Type", "application/json") 85 + if inpenc != "" { 86 + req.Header.Set("Content-Type", inpenc) 87 87 } 88 88 89 89 if c.Auth != nil {