this repo has no description
0
fork

Configure Feed

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

lexgen: more flexibility

- allows */* as output type (for blob fetches)
- handles "defs" (with not 'main' type)
- clearer log/warning messages

+9 -8
+9 -8
lex/gen.go
··· 409 409 params = fmt.Sprintf("%s, input *%s_Input", params, fname) 410 410 411 411 default: 412 - return fmt.Errorf("unsupported input encoding: %q", s.Input.Encoding) 412 + return fmt.Errorf("unsupported input encoding (RPC input): %q", s.Input.Encoding) 413 413 } 414 414 } 415 415 ··· 441 441 442 442 out = fmt.Sprintf("(*%s, error)", outname) 443 443 default: 444 - return fmt.Errorf("unrecognized encoding scheme: %q", s.Output.Encoding) 444 + return fmt.Errorf("unrecognized encoding scheme (RPC output): %q", s.Output.Encoding) 445 445 } 446 446 } 447 447 ··· 467 467 errRet = "nil, err" 468 468 outRet = "&out, nil" 469 469 default: 470 - return fmt.Errorf("unrecognized output encoding: %q", s.Output.Encoding) 470 + return fmt.Errorf("unrecognized output encoding (func signature): %q", s.Output.Encoding) 471 471 } 472 472 } 473 473 ··· 574 574 575 575 main, ok := s.Defs["main"] 576 576 if !ok { 577 - return fmt.Errorf("2 schema %q doesn't have a main def", s.ID) 577 + fmt.Printf("WARNING: schema %q doesn't have a main def\n", s.ID) 578 + continue 578 579 } 579 580 580 581 if main.Type == "procedure" || main.Type == "query" { ··· 729 730 outname = s.typeNameFromRef(s.Output.Schema.Ref) 730 731 } 731 732 returndef = fmt.Sprintf("(*%s.%s, error)", impname, outname) 732 - case "application/cbor", "application/vnd.ipld.car": 733 + case "application/cbor", "application/vnd.ipld.car", "*/*": 733 734 returndef = fmt.Sprintf("(io.Reader, error)") 734 735 default: 735 - return fmt.Errorf("unrecognized output encoding: %q", s.Output.Encoding) 736 + return fmt.Errorf("unrecognized output encoding (handler stub): %q", s.Output.Encoding) 736 737 } 737 738 } 738 739 ··· 925 926 fmt.Fprintf(w, "var out io.Reader\n") 926 927 returndef = "(io.Reader, error)" 927 928 default: 928 - return fmt.Errorf("unrecognized output encoding (1): %q", s.Output.Encoding) 929 + return fmt.Errorf("unrecognized output encoding (RPC output handler): %q", s.Output.Encoding) 929 930 } 930 931 } 931 932 fmt.Fprintf(w, "var handleErr error\n") ··· 944 945 case EncodingCAR: 945 946 fmt.Fprintf(w, "return c.Stream(200, \"application/vnd.ipld.car\", out)\n}\n\n") 946 947 default: 947 - return fmt.Errorf("unrecognized output encoding (2): %q", s.Output.Encoding) 948 + return fmt.Errorf("unrecognized output encoding (RPC output handler return): %q", s.Output.Encoding) 948 949 } 949 950 } else { 950 951 fmt.Fprintf(w, "return nil\n}\n\n")