Skip to content
This repository was archived by the owner on Aug 4, 2026. It is now read-only.

Latest commit

 

History

History
152 lines (102 loc) · 3.59 KB

Types.md

File metadata and controls

152 lines (102 loc) · 3.59 KB

Types

Type Candid

type Candid = Candid.Candid

Type HeaderField

type HeaderField = (Text, Text)

Type HttpRequest

type HttpRequest = { url : Text; method : Text; body : Blob; headers : [HeaderField] }

Type StreamingToken

type StreamingToken = Candid

Type StreamingResponse

type StreamingResponse = { token : ?StreamingToken; body : Blob }

Type StreamingCallback

type StreamingCallback = shared query (StreamingToken) -> async StreamingResponse

Type StreamingStrategy

type StreamingStrategy = {#Callback : { token : StreamingToken; callback : StreamingCallback }}

Type HttpResponse

type HttpResponse = { status_code : Nat16; body : Blob; headers : [HeaderField]; upgrade : ?Bool; streaming_strategy : ?StreamingStrategy }

Type URL

type URL = { text : Text; protocol : Text; port : Nat16; host : Text; path : Text; segments : [Text]; query_map : TrieMap.TrieMap<Text, Text>; query_text : () -> Text; query_candid : () -> Blob; anchor : Text }

Type Form

type Form = { get : (Text) -> ?[Text]; trieMap : TrieMap.TrieMap<Text, [Text]>; keys : [Text]; fileKeys : [Text]; files : (Text) -> ?[File] }

Type Headers

type Headers = { original : [(Text, Text)]; get : (Text) -> ?[Text]; trieMap : TrieMap.TrieMap<Text, [Text]>; keys : [Text] }

Type File

type File = { name : Text; filename : Text; mimeType : Text; mimeSubType : Text; start : Nat; end : Nat; bytes : Buffer.Buffer<Nat8> }

Type Body

type Body = { original : Blob; size : Nat; form : Form; text : () -> Text; file : () -> ?Buffer.Buffer<Nat8>; bytes : (start : Nat, end : Nat) -> Buffer.Buffer<Nat8> }

Type FormObjType

type FormObjType = { get : (Text) -> ?[Text]; trieMap : TrieMap.TrieMap<Text, [Text]>; keys : [Text]; fileKeys : [Text]; files : (Text) -> ?[File] }

Type ParsedHttpRequest

type ParsedHttpRequest = { method : Text; url : URL; headers : Headers; body : ?Body }

Type SharedMessage

type SharedMessage = { caller : Principal }

Type HttpHeader

type HttpHeader = { name : Text; value : Text }

Canister HTTP outcall request and response types

Type HttpMethod

type HttpMethod = {#get; #post; #head}

Type TransformContext

type TransformContext = { function : shared query TransformArgs -> async CanisterHttpResponse; context : Blob }

Type CanisterHttpRequest

type CanisterHttpRequest = { url : Text; max_response_bytes : ?Nat64; headers : [HttpHeader]; body : ?[Nat8]; method : HttpMethod; transform : ?TransformContext }

Type CanisterHttpResponse

type CanisterHttpResponse = { status : Nat; headers : [HttpHeader]; body : [Nat8] }

Type RedirectedResponse

type RedirectedResponse = { url : Text; response : CanisterHttpResponse }

Type OutcallResponse

type OutcallResponse = CanisterHttpResponse and { redirects : [RedirectedResponse] }

Type TransformArgs

type TransformArgs = { response : CanisterHttpResponse; context : Blob }

Type ManagementCanister

type ManagementCanister = actor { http_request : shared CanisterHttpRequest -> async CanisterHttpResponse }