Skip to content

Commit 6c5c58a

Browse files
committed
fix: unsused middleware code
1 parent 3c12589 commit 6c5c58a

2 files changed

Lines changed: 1 addition & 30 deletions

File tree

.github/workflows/audit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
run: staticcheck ./...
3434

3535
- name: Run Tests
36-
run: go test -race ./..
36+
run: go test -race ./...

cmd/api/users.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"context"
54
"net/http"
65
"strconv"
76

@@ -155,34 +154,6 @@ func (app *application) activateUserHandler(w http.ResponseWriter, r *http.Reque
155154
}
156155
}
157156

158-
func (app *application) userContextMiddleware(next http.Handler) http.Handler {
159-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
160-
userID, err := strconv.ParseInt(chi.URLParam(r, "userID"), 10, 64)
161-
if err != nil {
162-
app.badRequestResponse(w, r, err)
163-
return
164-
}
165-
166-
ctx := r.Context()
167-
168-
user, err := app.store.Users.GetByID(ctx, userID)
169-
if err != nil {
170-
switch err {
171-
case store.ErrNotFound:
172-
app.notFoundResponse(w, r, err)
173-
return
174-
default:
175-
app.internalServerError(w, r, err)
176-
return
177-
}
178-
}
179-
180-
ctx = context.WithValue(ctx, userCtx, user)
181-
182-
next.ServeHTTP(w, r.WithContext(ctx))
183-
})
184-
}
185-
186157
func getUserFromContext(r *http.Request) *store.User {
187158
user, _ := r.Context().Value(userCtx).(*store.User)
188159
return user

0 commit comments

Comments
 (0)