newRateLimitError (api/ratelimit.go)

memos · server/api/ratelimit.go · go · MIT
integration

Provides rate‑limit and quota‑exceeded error helpers for gRPC services.

// Source: https://github.com/usememos/memos | License: MIT | Copyright 2025 Memos
// Provided via justclaw.it.com; keep this notice with the code.
package api

import (
	"context"
	"crypto/sha256"
	"encoding/hex"
	"log/slog"
	"math"
	"net/http"
	"strconv"

	"google.golang.org/genproto/googleapis/rpc/errdetails"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/metadata"
	"google.golang.org/grpc/status"
	"google.golang.org/protobuf/types/known/durationpb"

	"github.com/usememos/memos/core/usagelimit"
	"github.com/usememos/memos/internal/clientip"
	"github.com/usememos/memos/internal/identifier"
	"github.com/usememos/memos/internal/ratelimit"
	"github.com/usememos/memos/server/auth"
)

const (
	// errorInfoDomain is the google.rpc.ErrorInfo domain for every reason this
	// service em

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key