In this example are the globalMiddleware ever set up?
jcoyne opened this issue · comments
I'm not seeing where restapi.configureAPI
is called (which sets up the middleware).
kvstore/gen/restapi/configure_kvstore.go
Line 26 in 11b3b4f
Am I missing something?
In this example it's not really used but its functionality is included in the ./cmd/kvstored/main.go
from the readme:
This application chooses to configure itself differently than the default generated code because it's more convenient and allows for a nicer structure.
The configuration happens in$project_root/cmd/kvstored
.
the middlewares are set up here: https://github.com/go-openapi/kvstore/blob/master/cmd/kvstored/main.go#L73-L78
Great. Thanks for the tip. I was just wondering, if this structure is nicer, is there any reason go-swagger doesn't generate it in this way?
you can get it to generate this initial structure more or less. The problem is for repeat generations. So we allow for generating with --skip-main and then you get to define your own main function which provides this use case.
What makes it nicer is not necessarily the programming experience but the new ability to just blow away the entire ./gen folder and regenerate it without having to repeat the setup customization.
However we try very hard not to introduce breaking changes, and removing the configure_xxx file would cause breakage for many people.
@casualjim excellent, that's what we're trying to be able to do too, keep all our changes outside of the gen/
directory so we can blow it away. It's too bad there doesn't seem to be a way for the generated configure_xxx file to not overwrite any handlers on the api that are already set up.