haxetink / tink_web

Tinkerbell Web Framework
https://haxetink.github.io/tink_web
43 stars 14 forks source link

get FQDN in request #93

Closed varadig closed 5 years ago

varadig commented 5 years ago

How to get current FQDN in request like this

@:post function foo(query:{}){ //how to get FQDN?? }

kevinresol commented 5 years ago

I don't think this is a problem of tink_web...

varadig commented 5 years ago

its not a problem, it is a question

varadig commented 5 years ago

So if there is no common way, I need to use nodejs to resolve FWDN? It is not a problem, I just looking a best practice to do that

kevinresol commented 5 years ago

Well yeah i don't think there are any best practice about that in tink web

varadig commented 5 years ago

Ok, so this is what the best I can do:

this.httpServer = js.node.Http.createServer(function(request, response) {
        //store somewhere
        somewhere = request.headers.get("host");
});

this.httpServer.listen(PORT);
this.container = new NodeContainer(this.httpServer);
kevinresol commented 5 years ago

If you decide to obtain such information in the header, you can fetch the Context object.

function route (ctx:Context) return ctx.request.header.ofName(HOST);