Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS: Fix panic due to unsafe type assertion #111

Merged
merged 6 commits into from
Jan 13, 2022

Conversation

ernesto-jimenez
Copy link

The generated code was making an unnecessary type assertion from http.Handler to http.HandlerFunc that was panicking when trying to use CORS for a service with Files.

This fixes the problem.

The change is split into multiple commits to hopefully help with the review.

Ernesto Jiménez added 6 commits January 13, 2022 13:51
--- FAIL: TestMountIndexHTML (0.00s)
panic: interface conversion: http.Handler is *http.fileHandler, not
http.HandlerFunc [recovered]
  panic: interface conversion: http.Handler is *http.fileHandler, not
http.HandlerFunc

goroutine 20 [running]:
testing.tRunner.func1.2({0x104907a40, 0x140000ab9e0})
  /opt/homebrew/Cellar/go/1.17.3/libexec/src/testing/testing.go:1209
+0x258
testing.tRunner.func1(0x140000829c0)
  /opt/homebrew/Cellar/go/1.17.3/libexec/src/testing/testing.go:1212
+0x284
panic({0x104907a40, 0x140000ab9e0})
  /opt/homebrew/Cellar/go/1.17.3/libexec/src/runtime/panic.go:1038
+0x21c
goa.design/plugins/v3/cors/examples/calc/gen/http/calc/server.HandleCalcOrigin({0x10496a9c0,
0x14000094e30})
  /Users/_/go/src/goa.design/plugins/cors/examples/calc/gen/http/calc/server/server.go:175
+0xe8
goa.design/plugins/v3/cors/examples/calc/gen/http/calc/server.MountIndexHTML({0x104972478,
0x14000096218}, {0x10496a9c0, 0x14000094e30})
  /Users/_/go/src/goa.design/plugins/cors/examples/calc/gen/http/calc/server/server.go:147
+0x30
goa.design/plugins/v3/cors/examples/calc/gen/http/calc/server.Mount({0x104972478,
0x14000096218}, 0x140000ba0a0)
  /Users/_/go/src/goa.design/plugins/cors/examples/calc/gen/http/calc/server/server.go:91
+0x94
goa.design/plugins/v3/cors/examples/calc.TestMountIndexHTML(0x140000829c0)
  /Users/_/go/src/goa.design/plugins/cors/examples/calc/calc_test.go:16
+0xdc
testing.tRunner(0x140000829c0, 0x104966990)
  /opt/homebrew/Cellar/go/1.17.3/libexec/src/testing/testing.go:1259
+0x104
created by testing.(*T).Run
  /opt/homebrew/Cellar/go/1.17.3/libexec/src/testing/testing.go:1306
+0x328
FAILgoa.design/plugins/v3/cors/examples/calc0.157s
FAIL
@raphael
Copy link
Member

raphael commented Jan 13, 2022

This is great and a bit of a doh! Thank you.

@raphael raphael merged commit 1de56e2 into goadesign:v3 Jan 13, 2022
@ernesto-jimenez
Copy link
Author

My pleasure! Thanks for merging it so quickly.

@ernesto-jimenez ernesto-jimenez deleted the fix-cors branch January 13, 2022 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants