ardanlabs / service

Starter-kit for writing services in Go using Kubernetes.
https://www.ardanlabs.com
Apache License 2.0
3.59k stars 649 forks source link

optimise cors response #426

Closed luxcgo closed 1 month ago

luxcgo commented 1 month ago

I've tested it locally, with the last commit, this finally works. Both simple requests and preflight requests need CORS headers. Maybe this can be refactored in a better way, but this is what needed for it to work with minimal changes.

ardan-bkennedy commented 1 month ago

If you can think of a better way to provide this support within the scope of the web package I'm all ears. I appreciate the fixes. When I switched to the new handler signature it added some wrenches in the mix. Everything is a tradeoff.

Heads up, for most of my projects I merge the API and APP layer together. The APP layer handlers use the web.HandlerFunc function signatures. I do plan to add GRPC to this project so people can see the benefit of separating the API and APP layers.

luxcgo commented 1 month ago

Yes, I was a little confused about the separations between the api layer and app layer. Now if grpc part is added, it makes sense. Btw, will the tool that auto generate the api docs work in the future?

ardan-bkennedy commented 1 month ago

I'm sorry I removed that, but is was very fragile. I didn't implement the tooling properly.

My plan is to try and use an LLM for both docs and generating new domains based on a data model. I'm just underwater and have not been able to get to that. Maybe by the end of the year.

ardan-bkennedy commented 1 month ago

If you want access to the latest version of the Ultimate Software Design class let me know. It might help you understand the code and some of the decisions better. It seems you've got a strong handle on things.

luxcgo commented 1 month ago

That'll be great, thank you.

ardan-bkennedy commented 1 month ago

Send me an email to bill@ardanlabs.com and I will get you that coupon code.