Skip to content

Commit

Permalink
Revert "Remove semicolons"
Browse files Browse the repository at this point in the history
This reverts commit ce24bff.
  • Loading branch information
elliottt committed Oct 6, 2023
1 parent ce24bff commit 0a8b941
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
8 changes: 4 additions & 4 deletions wit/handler.wit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// that takes a `request` parameter and returns a `response` result.
//
interface incoming-handler {
use types.{incoming-request, response-outparam}
use types.{incoming-request, response-outparam};

// The `handle` function takes an outparam instead of returning its response
// so that the component may stream its response while streaming any other
Expand All @@ -20,7 +20,7 @@ interface incoming-handler {
handle: func(
request: incoming-request,
response-out: response-outparam
)
);
}

// The `wasi:http/outgoing-handler` interface is meant to be imported by
Expand All @@ -31,7 +31,7 @@ interface incoming-handler {
// that takes a `request` parameter and returns a `response` result.
//
interface outgoing-handler {
use types.{outgoing-request, request-options, future-incoming-response, error}
use types.{outgoing-request, request-options, future-incoming-response, error};

// The parameter and result types of the `handle` function allow the caller
// to concurrently stream the bodies of the outgoing request and the incoming
Expand All @@ -41,5 +41,5 @@ interface outgoing-handler {
handle: func(
request: outgoing-request,
options: option<request-options>
) -> result<future-incoming-response, error>
) -> result<future-incoming-response, error>;
}
20 changes: 10 additions & 10 deletions wit/proxy.wit
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package wasi:http
package wasi:http;

// The `wasi:http/proxy` world captures a widely-implementable intersection of
// hosts that includes HTTP forward and reverse proxies. Components targeting
// this world may concurrently stream in and out any number of incoming and
// outgoing HTTP requests.
world proxy {
// HTTP proxies have access to time and randomness.
import wasi:clocks/wall-clock
import wasi:clocks/monotonic-clock
import wasi:clocks/timezone
import wasi:random/random
import wasi:clocks/wall-clock;
import wasi:clocks/monotonic-clock;
import wasi:clocks/timezone;
import wasi:random/random;

// Proxies have standard output and error streams which are expected to
// terminate in a developer-facing console provided by the host.
import wasi:cli/stdout
import wasi:cli/stderr
import wasi:cli/stdout;
import wasi:cli/stderr;

// TODO: this is a temporary workaround until component tooling is able to
// gracefully handle the absence of stdin. Hosts must return an eof stream
// for this import, which is what wasi-libc + tooling will do automatically
// when this import is properly removed.
import wasi:cli/stdin
import wasi:cli/stdin;

// This is the default handler to use when user code simply wants to make an
// HTTP request (e.g., via `fetch()`).
import outgoing-handler
import outgoing-handler;

// The host delivers incoming HTTP requests to a component by calling the
// `handle` function of this exported interface. A host may arbitrarily reuse
// or not reuse component instance when delivering incoming HTTP requests and
// thus a component must be able to handle 0..N calls to `handle`.
export incoming-handler
export incoming-handler;
}
68 changes: 34 additions & 34 deletions wit/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// define the HTTP resource types and operations used by the component's
// imported and exported interfaces.
interface types {
use wasi:io/streams.{input-stream, output-stream}
use wasi:io/poll.{pollable}
use wasi:io/streams.{input-stream, output-stream};
use wasi:io/poll.{pollable};

// This type corresponds to HTTP standard Methods.
variant method {
Expand Down Expand Up @@ -43,28 +43,28 @@ interface types {
resource fields {
// Multiple values for a header are multiple entries in the list with the
// same key.
constructor(entries: list<tuple<string,list<u8>>>)
constructor(entries: list<tuple<string,list<u8>>>);

// Values off wire are not necessarily well formed, so they are given by
// list<u8> instead of string.
get: func(name: string) -> list<list<u8>>
get: func(name: string) -> list<list<u8>>;

// Values off wire are not necessarily well formed, so they are given by
// list<u8> instead of string.
set: func(name: string, value: list<list<u8>>)
delete: func(name: string)
append: func(name: string, value: list<u8>)
set: func(name: string, value: list<list<u8>>);
delete: func(name: string);
append: func(name: string, value: list<u8>);

// Values off wire are not necessarily well formed, so they are given by
// list<u8> instead of string.
entries: func() -> list<tuple<string,list<u8>>>
entries: func() -> list<tuple<string,list<u8>>>;

// Deep copy of all contents in a fields.
clone: func() -> fields
clone: func() -> fields;
}

type headers = fields
type trailers = fields
type headers = fields;
type trailers = fields;

// The following block defines the `incoming-request` and `outgoing-request`
// resource types that correspond to HTTP standard Requests. Soon, when
Expand All @@ -75,19 +75,19 @@ interface types {
// above). The `consume` and `write` methods may only be called once (and
// return failure thereafter).
resource incoming-request {
method: func() -> method
method: func() -> method;

path-with-query: func() -> option<string>
path-with-query: func() -> option<string>;

scheme: func() -> option<scheme>
scheme: func() -> option<scheme>;

authority: func() -> option<string>
authority: func() -> option<string>;

headers: func() -> headers
headers: func() -> headers;

// Will return the incoming-body child at most once. If called more than
// once, subsequent calls will return error.
consume: func() -> result<incoming-body>
consume: func() -> result<incoming-body>;
}

resource outgoing-request {
Expand All @@ -97,11 +97,11 @@ interface types {
scheme: option<scheme>,
authority: option<string>,
headers: borrow<headers>
)
);

// Will return the outgoing-body child at most once. If called more than
// once, subsequent calls will return error.
write: func() -> result<outgoing-body>
write: func() -> result<outgoing-body>;
}

// Additional optional parameters that can be set when making a request.
Expand All @@ -127,11 +127,11 @@ interface types {
// (the `wasi:http/handler` interface used for both incoming and outgoing can
// simply return a `stream`).
resource response-outparam {
set: static func(param: response-outparam, response: result<outgoing-response, error>)
set: static func(param: response-outparam, response: result<outgoing-response, error>);
}

// This type corresponds to the HTTP standard Status Code.
type status-code = u16
type status-code = u16;

// The following block defines the `incoming-response` and `outgoing-response`
// resource types that correspond to HTTP standard Responses. Soon, when
Expand All @@ -141,55 +141,55 @@ interface types {
// type (that uses the single `stream` type mentioned above). The `consume` and
// `write` methods may only be called once (and return failure thereafter).
resource incoming-response {
status: func() -> status-code
status: func() -> status-code;

headers: func() -> headers
headers: func() -> headers;

// May be called at most once. returns error if called additional times.
// TODO: make incoming-request-consume work the same way, giving a child
// incoming-body.
consume: func() -> result<incoming-body>
consume: func() -> result<incoming-body>;
}

resource incoming-body {
// returned input-stream is a child - the implementation may trap if
// incoming-body is dropped (or consumed by call to
// incoming-body-finish) before the input-stream is dropped.
// May be called at most once. returns error if called additional times.
%stream: func() -> result<input-stream>
%stream: func() -> result<input-stream>;

// takes ownership of incoming-body. this will trap if the
// incoming-body-stream child is still alive!
finish: static func(this: incoming-body) -> future-trailers
finish: static func(this: incoming-body) -> future-trailers;
}

resource future-trailers {
/// Pollable that resolves when the body has been fully read, and the trailers
/// are ready to be consumed.
subscribe: func() -> pollable
subscribe: func() -> pollable;

/// Retrieve reference to trailers, if they are ready.
get: func() -> option<result<trailers, error>>
get: func() -> option<result<trailers, error>>;
}

resource outgoing-response {
constructor(status-code: status-code, headers: borrow<headers>)
constructor(status-code: status-code, headers: borrow<headers>);

/// Will give the child outgoing-response at most once. subsequent calls will
/// return an error.
write: func() -> result<outgoing-body>
write: func() -> result<outgoing-body>;
}

resource outgoing-body {
/// Will give the child output-stream at most once. subsequent calls will
/// return an error.
write: func() -> result<output-stream>
write: func() -> result<output-stream>;

/// Finalize an outgoing body, optionally providing trailers. This must be
/// called to signal that the response is complete. If the `outgoing-body` is
/// dropped without calling `outgoing-body-finalize`, the implementation
/// should treat the body as corrupted.
finish: static func(this: outgoing-body, trailers: option<trailers>)
finish: static func(this: outgoing-body, trailers: option<trailers>);
}

/// The following block defines a special resource type used by the
Expand All @@ -206,8 +206,8 @@ interface types {
/// will return an error here.
/// inner result indicates whether the incoming-response was available, or an
/// error occured.
get: func() -> option<result<result<incoming-response, error>>>
get: func() -> option<result<result<incoming-response, error>>>;

subscribe: func() -> pollable
subscribe: func() -> pollable;
}
}

0 comments on commit 0a8b941

Please sign in to comment.