- Add backend/libs/go-http-errors for consistent JSON errors - REST API: use writeMethodNotAllowed, writeNotFound, writeInternalError - middleware, gateway, search: use httperrors.WriteJSON - SPA: navbar with Explore/Tools/More dropdowns, initNavDropdowns() - Next.js: Navbar component with dropdowns + mobile menu Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package rest
|
|
|
|
import (
|
|
_ "embed"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed config/metamask/DUAL_CHAIN_NETWORKS.json
|
|
var dualChainNetworksJSON []byte
|
|
|
|
//go:embed config/metamask/DUAL_CHAIN_TOKEN_LIST.tokenlist.json
|
|
var dualChainTokenListJSON []byte
|
|
|
|
// handleConfigNetworks serves GET /api/config/networks (Chain 138 + Ethereum Mainnet params for wallet_addEthereumChain).
|
|
func (s *Server) handleConfigNetworks(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
w.Header().Set("Allow", "GET")
|
|
writeMethodNotAllowed(w)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Cache-Control", "public, max-age=3600")
|
|
w.Write(dualChainNetworksJSON)
|
|
}
|
|
|
|
// handleConfigTokenList serves GET /api/config/token-list (Uniswap token list format for MetaMask).
|
|
func (s *Server) handleConfigTokenList(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
w.Header().Set("Allow", "GET")
|
|
writeMethodNotAllowed(w)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Header().Set("Cache-Control", "public, max-age=3600")
|
|
w.Write(dualChainTokenListJSON)
|
|
}
|