-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for Go 1.22+ net/http routing
As part of #1068, we want to add support for the new Go 1.22+ `net/http`-only router, which will allow using `oapi-codegen` with reduced external dependencies. This requires we: - wire in a new server, `std-http` - add relevant templates for the router and strict server - conditionally build/test/lint/etc the code when running on older versions of Go, which requires a bit of work in our `Makefile` - use a separate module for the generated code, as it must set `go 1.22` in the `go.mod` - document the fact that the `go.mod` needs updating, too, as it's caused some time to be lost in the past Closes #1068. Co-authored-by: Jamie Tanna <jamie@jamietanna.co.uk> Signed-off-by: Donnie Adams <donnie@acorn.io>
- Loading branch information
1 parent
74e9346
commit dd08298
Showing
31 changed files
with
3,523 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
SHELL:=/bin/bash | ||
|
||
YELLOW := \e[0;33m | ||
RESET := \e[0;0m | ||
|
||
GOVER := $(shell go env GOVERSION) | ||
GOMINOR := $(shell bash -c "cut -f2 -d. <<< $(GOVER)") | ||
|
||
define execute-if-go-122 | ||
@{ \ | ||
if [[ 22 -le $(GOMINOR) ]]; then \ | ||
$1; \ | ||
else \ | ||
echo -e "$(YELLOW)Skipping task as you're running Go v1.$(GOMINOR).x which is < Go 1.22, which this module requires$(RESET)"; \ | ||
fi \ | ||
} | ||
endef | ||
|
||
lint: | ||
$(call execute-if-go-122,$(GOBIN)/golangci-lint run ./...) | ||
|
||
lint-ci: | ||
|
||
$(call execute-if-go-122,$(GOBIN)/golangci-lint run ./... --out-format=github-actions --timeout=5m) | ||
|
||
generate: | ||
$(call execute-if-go-122,go generate ./...) | ||
|
||
test: | ||
$(call execute-if-go-122,go test -cover ./...) | ||
|
||
tidy: | ||
$(call execute-if-go-122,go mod tidy) | ||
|
||
tidy-ci: | ||
$(call execute-if-go-122,tidied -verbose) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package: api | ||
generate: | ||
std-http-server: true | ||
embedded-spec: true | ||
models: true | ||
output: petstore.gen.go |
Oops, something went wrong.