Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit60b058a

Browse files
coadlerkylecarbs
authored andcommitted
chore: add api specific 404 (#1272)
Prevents weird errors when routes are moved, like#1205
1 parent934c258 commit60b058a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎coderd/coderd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func New(options *Options) (http.Handler, func()) {
6969
})
7070

7171
r:=chi.NewRouter()
72+
7273
r.Use(
7374
func(next http.Handler) http.Handler {
7475
returnhttp.HandlerFunc(func(w http.ResponseWriter,r*http.Request) {
@@ -80,6 +81,12 @@ func New(options *Options) (http.Handler, func()) {
8081
)
8182

8283
r.Route("/api/v2",func(r chi.Router) {
84+
r.NotFound(func(rw http.ResponseWriter,r*http.Request) {
85+
httpapi.Write(rw,http.StatusNotFound, httpapi.Response{
86+
Message:"Route not found.",
87+
})
88+
})
89+
8390
r.Use(
8491
// Specific routes can specify smaller limits.
8592
httpmw.RateLimitPerMinute(options.APIRateLimit),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp