26 lines
798 B
Go
26 lines
798 B
Go
package handlers
|
|
|
|
import "net/http"
|
|
|
|
// newInvalidateMembershipsHandler returns the handler for
|
|
// `POST /api/v1/internal/games/{game_id}/memberships/invalidate`. The
|
|
// underlying cache invalidation is a fire-and-forget local operation,
|
|
// so the handler always responds with `204 No Content` once the path
|
|
// parameter validates.
|
|
func newInvalidateMembershipsHandler(deps Dependencies) http.HandlerFunc {
|
|
return func(writer http.ResponseWriter, request *http.Request) {
|
|
if deps.InvalidateMemberships == nil {
|
|
writeError(writer, http.StatusInternalServerError, errorCodeInternal, "membership cache invalidator is not wired")
|
|
return
|
|
}
|
|
|
|
gameID, ok := extractGameID(writer, request)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
deps.InvalidateMemberships.Invalidate(gameID)
|
|
writeNoContent(writer)
|
|
}
|
|
}
|