Skip to content

Commit 6033550

Browse files
lvan100lianghuan
authored andcommitted
111
1 parent 36c088a commit 6033550

File tree

7 files changed

+45
-52
lines changed

7 files changed

+45
-52
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Generate Go server-side code and client code in other languages from IDL files:
4747

4848
* Data model structures
4949
* Parameter and data validation logic
50-
* Automatic HTTP request parameter binding (path, query, header, body)
50+
* Automatic HTTP request parameter binding (path, query, body)
5151
* Support for both regular and streaming (SSE) interfaces
5252
* Server interface definitions and route binding
5353
* Client-side call code
@@ -68,7 +68,7 @@ Generate Go server-side code and client code in other languages from IDL files:
6868

6969
### 🌐 HTTP-Friendly
7070

71-
* Automatic binding of HTTP request parameters (path, query, header, body)
71+
* Automatic binding of HTTP request parameters (path, query, body)
7272
* Supports `form`, `json`, and `multipart-form` formats
7373
* Native support for streaming RPC (SSE) interfaces
7474

gen/generator/golang/proto/http_handler.go

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/generator/golang/type.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const {{$c.Name}} {{$c.Type}} = {{$c.Value}}
140140
return &{{$s.Name}}{}
141141
}
142142
143-
// Binding extracts non-body values (header, path, query) from *http.Request.
143+
// Binding extracts non-body values (path, query) from *http.Request.
144144
func (x *{{$s.Name}}) Binding(r *http.Request) error {
145145
return Binding(r, []BindingField {
146146
{{- range $f := $s.Fields}}
@@ -370,9 +370,9 @@ type TypeField struct {
370370
Comment string
371371
}
372372

373-
// Binding represents a field binding from headers, path, or query
373+
// Binding represents a field binding from path, or query
374374
type Binding struct {
375-
From string // Source: header/path/query
375+
From string // Source: path/query
376376
Name string // Field name in the source
377377
}
378378

@@ -515,13 +515,13 @@ func convertType(ctx Context, t tidl.Type) (Type, error) {
515515
return Type{}, errutil.Explain(nil, "get type kind for field %s in type %s error: %w", f.Name, r.Name, err)
516516
}
517517

518-
// Parse HTTP binding info from annotations (header, path, query)
518+
// Parse HTTP binding info from annotations (path, query)
519519
binding, err := parseBinding(f.Annotations)
520520
if err != nil {
521521
return Type{}, errutil.Explain(nil, "parse binding for field %s in type %s error: %w", f.Name, r.Name, err)
522522
}
523523

524-
// Generate struct tag for JSON, query/path/header bindings
524+
// Generate struct tag for JSON, query/path bindings
525525
fieldTag, err := genFieldTag(f.Name, typeName, f.Annotations, binding)
526526
if err != nil {
527527
return Type{}, errutil.Explain(nil, "generate field tag for field %s in type %s error: %w", f.Name, r.Name, err)
@@ -664,9 +664,9 @@ func getTypeKind(ctx Context, typeName string) (TypeKind, error) {
664664
}
665665

666666
// parseBinding parses a field's HTTP binding information from annotations.
667-
// Supported sources: header, path, query.
667+
// Supported sources: path, query.
668668
func parseBinding(arr []tidl.Annotation) (*Binding, error) {
669-
a, ok := tidl.GetAnnotation(arr, "header", "path", "query")
669+
a, ok := tidl.GetAnnotation(arr, "path", "query")
670670
if !ok {
671671
return nil, nil
672672
}
@@ -681,7 +681,7 @@ func parseBinding(arr []tidl.Annotation) (*Binding, error) {
681681
}
682682

683683
// genFieldTag generates the struct tag for a Go struct field.
684-
// It includes JSON tags and optional binding tags (header, path, query).
684+
// It includes JSON tags and optional binding tags (path, query).
685685
func genFieldTag(fieldName, typeName string, arr []tidl.Annotation, binding *Binding) (string, error) {
686686
var tags []string
687687

gen/testdata/manager/go/proto/http_handler.go

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/testdata/manager/go/proto/manager.go

Lines changed: 25 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/testdata/manager/go/proto/stream.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/testdata/manager/idl/manager.idl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ type ListManagersByPageReq {
136136
Department? dept (query="dept")
137137
ManagerLevel? minLevel (query="minLevel")
138138
bool? vip (query="vip")
139-
string? authToken (header="X-Auth-Token")
140139
}
141140

142141
// ---- Response types ----

0 commit comments

Comments
 (0)