import Nat "mo:base/Nat";
import Text "mo:base/Text";
actor Counter {
public type Key = Text;
public type Path = Text;
public type Chunk_Id = Nat;
public type SetAssetContentArguments = {
key: Key;
sha256:?[Nat8];
chunk_ids: [Chunk_Id];
content_encoding: Text;
};
public type StreamingCallbackHttpResponse = {
token: ?StreamingCallbackToken;
body: Blob;
};
public type StreamingCallbackToken = {
key: Text;
sha256: ?[Nat8];
index:Nat;
content_encoding: Text;
};
public type StreamingStrategy = {
#Callback : {
token: StreamingCallbackToken;
Callback: shared query StreamingCallbackToken -> async StreamingCallbackHttpResponse;
};
};
public type HeaderField = (Text, Text);
public type HttpRequest = {
url: Text;
method: Text;
body: Blob;
headers: [HeaderField];
};
public type HttpResponse = {
body: Blob;
headers: [HeaderField];
streaming_strategy: ?StreamingStrategy;
status_code: Nat16;
};
public shared query func http_request(request: HttpRequest) : async HttpResponse {
{
body = Text.encodeUtf8("<html><body><h2>the counter is: " # Nat.toText(counter) # "</h2><body></html>");
headers = [];
streaming_strategy = null;
status_code= 200;
}
};
stable var counter = 0;
// Get the value of the counter.
public query func get() : async Nat {
return counter;
};
// Set the value of the counter.
public func set(n : Nat) : async () {
counter := n;
};
// Increment the value of the counter.
public func inc() : async () {
counter += 1;
};
};
第三课作业 motoko源码
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 此次文案写的是推介来自广东揭西的一家养蜂场的土蜂蜜产品系列。 我选用演绎法,我会在这里放入数据、讲故事、用权威、细...
- 1.昵称诱饵 昵称统一选用和羊绒相关的。 在群里抛诱饵时,承接自然,同时提供的实用技巧,技巧要方便可操作,最好立竿...
- 《第三课 作业主题》 D4成功率和短板 作业模版——项目资源系统诊断 ---- 7组--董永霞 项目名称:小班课 ...