FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add support for Gorilla generation (#585) · developgo/oapi-codegen@b3eedde · GitHub

Commit b3eedde

Browse files
Jamie Tanna
authored
Add support for Gorilla generation (oapi-codegen#585)
* Add support for Gorilla generation As part of oapi-codegen#465, it'd be handy to have gorilla/mux, a commonly used HTTP server as a generated server. This is very similar to Chi, as it is also `net/http` compliant, and allows us to mostly copy-paste the code, with very minor tweaks for Gorilla-specific routing needs. * Add example project for Gorilla As part of oapi-codegen#465, we should produce an example version of the Petstore API using Gorilla, to validate that this works, as well as showing sample usage to consumers.
1 parent cf98a10 commit b3eedde

17 files changed

Lines changed: 1157 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ func SetupHandler() {
255255
http.Handle("/", Handler(&myApi))
256256
}
257257
```
258+
259+
Alternatively, [Gorilla](https://github.com/gorilla/mux) is also 100% compatible with `net/http` and can be generated with `-generate gorilla`.
260+
258261
</summary></details>
259262

260263
#### Additional Properties in type definitions

‎cmd/oapi-codegen/oapi-codegen.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func main() {
8686
// All flags below are deprecated, and will be removed in a future release. Please do not
8787
// update their behavior.
8888
flag.StringVar(&flagGenerate, "generate", "types,client,server,spec",
89-
`Comma-separated list of code to generate; valid options: "types", "client", "chi-server", "server", "gin", "spec", "skip-fmt", "skip-prune"`)
89+
`Comma-separated list of code to generate; valid options: "types", "client", "chi-server", "server", "gin", "gorilla", "spec", "skip-fmt", "skip-prune"`)
9090
flag.StringVar(&flagIncludeTags, "include-tags", "", "Only include operations with the given tags. Comma-separated list of tags.")
9191
flag.StringVar(&flagExcludeTags, "exclude-tags", "", "Exclude operations that are tagged with the given tags. Comma-separated list of tags.")
9292
flag.StringVar(&flagTemplatesDir, "templates", "", "Path to directory containing user templates")
@@ -321,6 +321,8 @@ func newConfigFromOldConfig(c oldConfiguration) configuration {
321321
opts.Generate.EchoServer = true
322322
case "gin":
323323
opts.Generate.GinServer = true
324+
case "gorilla":
325+
opts.Generate.GorillaServer = true
324326
case "types":
325327
opts.Generate.Models = true
326328
case "spec":
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package: api
2+
generate:
3+
gorilla-server: true
4+
models: true
5+
embedded-spec: true
6+
output: petstore.gen.go

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL