Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote proxying (and support for opaque piping) #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tink/web/macros/Proxify.hx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Proxify {
fields: [for (f in routes) {
pos: f.field.pos,
name: f.field.name,
meta: f.field.meta.get(),
kind: FFun({
args: [for (arg in f.signature.args) switch arg.kind {
case AKSingle(_, ATUser(_) | ATContext): continue;
Expand Down Expand Up @@ -156,7 +157,7 @@ class Proxify {
ret;
}
var endPoint = makeEndpoint(path, f, headers);
var bodyCt = streaming ? macro:tink.io.IdealSource : macro:tink.Chunk;
var bodyCt = streaming ? macro:tink.io.Source.IdealSource : macro:tink.Chunk;

macro @:pos(f.field.pos) {
var __body__:$bodyCt = $body;
Expand Down
4 changes: 4 additions & 0 deletions src/tink/web/routing/Response.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ abstract Response(OutgoingResponse) from OutgoingResponse to OutgoingResponse {
static public function ofChunk(c:Chunk, ?contentType:String = BINARY)
return binary(null, contentType, c);

@:from static function fromIncomingresponse(r:IncomingResponse):Response
return new OutgoingResponse(new ResponseHeader(r.header.statusCode, r.header.statusCode, @:privateAccess r.header.fields.map(header ->
new HeaderField(header.name, header.value))), r.body.idealize(function(_) return Source.EMPTY));

@:from static function ofString(s:String):Response
return textual('text/plain', s);

Expand Down