Skip to content

Commit

Permalink
rename to MethodAnnotationsFromCtx
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek committed Sep 27, 2024
1 parent f8297fa commit 1af2de2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
37 changes: 19 additions & 18 deletions _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions _examples/golang-basics/example.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ service ExampleService
# Status endpoint
#
# gives you current status of running application
@internal
- Status() => (status: bool)
- Version() => (version: Version)
- GetUser(header: map<string,string>, userID: uint64) => (user: User)
Expand Down
29 changes: 15 additions & 14 deletions _examples/golang-imports/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions helpers.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (

MethodNameCtxKey = &contextKey{"MethodName"}

AnnotationsCtxKey = &contextKey{"Annotations"}
MethodAnnotationsCtxKey = &contextKey{"MethodAnnotations"}
)

func ServiceNameFromContext(ctx context.Context) string {
Expand All @@ -46,7 +46,7 @@ func RequestFromContext(ctx context.Context) *http.Request {
}

func MethodAnnotationsFromContext(ctx context.Context) map[string]string {
annotations, _ := ctx.Value(AnnotationsCtxKey).(map[string]string)
annotations, _ := ctx.Value(MethodAnnotationsCtxKey).(map[string]string)
return annotations
}

Expand Down
2 changes: 1 addition & 1 deletion server.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *{{$serviceName}}) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx = context.WithValue(ctx, HTTPResponseWriterCtxKey, w)
ctx = context.WithValue(ctx, HTTPRequestCtxKey, r)
ctx = context.WithValue(ctx, ServiceNameCtxKey, "{{.Name}}")
ctx = context.WithValue(ctx, AnnotationsCtxKey, annotations[r.URL.Path])
ctx = context.WithValue(ctx, MethodAnnotationsCtxKey, methodAnnotations[r.URL.Path])

if s.OnRequest != nil {
s.OnRequest(w, r)
Expand Down

0 comments on commit 1af2de2

Please sign in to comment.