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

routes won't return Promise<Tink.template.Html> as it used to.. #118

Open
postite opened this issue Oct 28, 2020 · 10 comments
Open

routes won't return Promise<Tink.template.Html> as it used to.. #118

postite opened this issue Oct 28, 2020 · 10 comments

Comments

@postite
Copy link

postite commented Oct 28, 2020

 @:get("/")
@:produces("text/html")
public function index(){
	return Promise.NOISE.next(n->
	Home.render() //tink.template 
	);
}

compiles with error.
tink.core.Promise<tink.template.Html> should be tink.io.RealSource

workaround :

Home.render().toString() // works fine. 

but it shouldn't behave like this huh ?

@kevinresol
Copy link
Member

what haxe version?

@postite
Copy link
Author

postite commented Oct 28, 2020

hello kevin .
I run haxe 4.1.4

@kevinresol
Copy link
Member

I reckon this is about transitivity.
Can you try adding @:transitive to tink.template.Html?

@postite
Copy link
Author

postite commented Oct 31, 2020

@:transitive
(:public static function render():)
<div id="home" class="page">
    <p>oh!</p> 
</div> 
(:end:)

is it where @:transition should be placed ? because it's causing compiler to not compile and stays forever at "building" status . I hate when it does this...

@kevinresol
Copy link
Member

it is for the abstract Html

@postite
Copy link
Author

postite commented Oct 31, 2020

ah ! oh !

package tink.template;

import tink.HtmlString;
import tink.htmlstring.HtmlBuffer as Buf;
@:transitive
abstract Html(HtmlString) from HtmlString to HtmlString { ...

I've done this ... but no change ... I don't get what @:transitive does ... so I'm completely lost here :)

@kevinresol
Copy link
Member

Anyway, if this problem is particular for tink_web, I suggest you use the @:html metadata instead

@:get("/")
@:html(_ -> Home.render())
public function index(){
	return Promise.NOISE;
}

@postite
Copy link
Author

postite commented Nov 2, 2020

ok nice to know. It doesn't work in my case cause i'm using static extensions ( like : Home.render().withLayout().addAction(Command1).render() ) but i'll go without.
btw , your exemple doesn't not render anything. It seems This one does :

@:get("/")
@:html(_ -> views.Home.render()) // full path
public function index(){
	return Promise.NOISE.next(n->{hip:"hop"}); // need a next ! ? 
}

thx for your efforts :) .

@kevinresol
Copy link
Member

I think this is a bug because Noise will produce empty http response but I think it should respect the html request.

@kevinresol
Copy link
Member

Code pointer for contributors:

case RNoise:
macro @:pos(pos) tink.core.Promise.lift($result).next(
function (_):tink.core.Promise<tink.web.routing.Response> {
return new tink.http.Response.OutgoingResponse(
new tink.http.Response.ResponseHeader(
$statusCode,
[new tink.http.Header.HeaderField(CONTENT_LENGTH, '0')].concat(${macro $a{headers}})
),
Chunk.EMPTY
);
}
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants