-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4225ad8
commit f18b3e3
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Array "mo:base/Array"; | ||
import Blob "mo:base/Blob"; | ||
import Char "mo:base/Char"; | ||
import Cycles "mo:base/ExperimentalCycles"; | ||
import Debug "mo:base/Debug"; | ||
import HashMap "mo:base/HashMap"; | ||
import Hash "mo:base/Hash"; | ||
import Nat "mo:base/Nat"; | ||
import Nat32 "mo:base/Nat32"; | ||
import Nat64 "mo:base/Nat64"; | ||
import Option "mo:base/Option"; | ||
import Principal "mo:base/Principal"; | ||
import Text "mo:base/Text"; | ||
import Time "mo:base/Time"; | ||
import Trie "mo:base/Trie"; | ||
import TrieMap "mo:base/TrieMap"; | ||
import Buffer "mo:base/Buffer"; | ||
import Int "mo:base/Int"; | ||
import Iter "mo:base/Iter"; | ||
import Error "mo:base/Error"; | ||
import List "mo:base/List"; | ||
import AssocList "mo:base/AssocList"; | ||
import Float "mo:base/Float"; | ||
import Map "mo:map/Map"; | ||
import Types "../Types"; | ||
import Utils "../Utils"; | ||
import HttpTypes "../HttpTypes"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module Types { | ||
|
||
public type Timestamp = Nat64; | ||
|
||
//See: https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-http_request | ||
public type HttpRequestArgs = { | ||
url : Text; | ||
max_response_bytes : ?Nat64; | ||
headers : [HttpHeader]; | ||
body : ?[Nat8]; | ||
method : HttpMethod; | ||
transform : ?TransformRawResponseFunction; | ||
}; | ||
|
||
public type HttpHeader = { | ||
name : Text; | ||
value : Text; | ||
}; | ||
|
||
public type HttpMethod = { | ||
#get; | ||
#post; | ||
#head; | ||
}; | ||
|
||
public type HttpResponsePayload = { | ||
status : Nat; | ||
headers : [HttpHeader]; | ||
body : [Nat8]; | ||
}; | ||
|
||
//2. HTTPS outcalls have an optional "transform" key. These two types help describe it. | ||
//"The transform function may, for example, transform the body in any way, add or remove headers, | ||
//modify headers, etc. " | ||
//See: https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-http_request | ||
public type TransformRawResponseFunction = { | ||
function : shared query TransformArgs -> async HttpResponsePayload; | ||
context : Blob; | ||
}; | ||
|
||
// This Type defines the arguments the transform function needs. | ||
public type TransformArgs = { | ||
response : HttpResponsePayload; | ||
context : Blob; | ||
}; | ||
|
||
public type IC = actor { | ||
http_request : HttpRequestArgs -> async HttpResponsePayload; | ||
}; | ||
|
||
public type MainActor = actor { | ||
transform_response : shared query TransformArgs -> async HttpResponsePayload; | ||
}; | ||
}; |