Solana documentatieInfrastructure als CodeStandaardbibliotheek

Standaardacties

Deze acties zijn beschikbaar in alle Runbooks als onderdeel van de standaardbibliotheek.

send_http_request

De actie std::send_http_request maakt een HTTP-verzoek naar de opgegeven URL.

Invoer

NaamVereistTypeBeschrijving
urlvereiststringDe URL waarnaar het verzoek wordt gestuurd
methodoptioneelstringDe HTTP-methode (GET, POST, PUT, DELETE). Standaard: GET
headersoptioneelmapHTTP-headers om op te nemen in het verzoek
bodyoptioneelstringDe verzoekbody (voor POST/PUT-verzoeken)
timeout_msoptioneelintegerVerzoektime-out in milliseconden

Uitvoer

NaamTypeBeschrijving
status_codeintegerDe HTTP-statuscode
bodystringDe responsbody
headersmapDe responsheaders
action "api_call" "std::send_http_request" {
description = "Fetch data from API"
url = "https://api.example.com/data"
method = "GET"
headers = {
"Authorization" = "Bearer ${variable.token}"
}
}
output "response" {
value = action.api_call.body
}
output "status" {
value = action.api_call.status_code
}

Voorbeeld POST-verzoek

action "create_resource" "std::send_http_request" {
description = "Create a new resource"
url = "https://api.example.com/resources"
method = "POST"
headers = {
"Content-Type" = "application/json"
}
body = {
"name" = variable.name,
"value" = variable.value
}
}

Is this page helpful?

Inhoudsopgave

Pagina Bewerken
© 2026 Solana Foundation. Alle rechten voorbehouden.