diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-06-28 23:59:50 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-06-28 23:59:50 +0200 |
commit | 67dbb6421976254658c5e38045513129dd18187a (patch) | |
tree | 288b599d1097b26bdbcad3b6749b38e133017cf2 /core/http/client.ts |
initial public commit
Diffstat (limited to 'core/http/client.ts')
-rw-r--r-- | core/http/client.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/http/client.ts b/core/http/client.ts new file mode 100644 index 0000000..42d75f0 --- /dev/null +++ b/core/http/client.ts @@ -0,0 +1,31 @@ +import { ParseDepth, ParseResult } from "../../language/types.ts"; +import YomikunError from "../../util/error.ts"; +import API from "../api.ts"; +import { ConnectionProps, ConnectionPropsDefault } from "./props.ts"; + +/** + * @summary Yomikun HTTP API + * + * Uses the Yomikun server to call API methods. Handles (de)serialization + * automatically. + */ +export default class YomikunRemoteAPIClient implements API { + private props: ConnectionProps; + + constructor(options?: ConnectionProps) { + this.props = { ...ConnectionPropsDefault, ...options }; + } + + async prepare() { } + + async parseSentence(input: string) { + var response = await fetch(`http://${this.props.host}:${this.props.port}/parseSentence`); + console.log(response.body); + + return { + depth: ParseDepth.Term, + tokens: [], + } as ParseResult; + } +} + |