How to serve a HTML asset

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to serve a HTML asset

geemang
OK, noob question.  Can't find an example...

How can you serve an asset from a handler?

See get("boot") get handler (doesn't work).

ratpack {
        handlers {

                get("boot") {
                        render "bootstrap.html"
                }

                assets "public", "index.html"
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: How to serve a HTML asset

Luke Daley
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: How to serve a HTML asset

geemang
Thanks!  

Here is the working handler.

ratpack {
        handlers {

                get("boot") {
                        response.sendFile "text/html", file("public/bootstrap.html")
                }

                assets "public", "index.html"
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: How to serve a HTML asset

Luke Daley
Administrator
Great.

This has given me an idea. I'm going to make the following work in addition to what works today…

render file("public/bootstrap.html")
Reply | Threaded
Open this post in threaded view
|

Re: How to serve a HTML asset

geemang
I like it! Was hoping for something more elegant.
Reply | Threaded
Open this post in threaded view
|

Re: How to serve a HTML asset

Luke Daley
Administrator