add HTML rendering capabilities and helper functions
This commit is contained in:
+17
-1
@@ -10,9 +10,14 @@ import (
|
||||
func main() {
|
||||
r := ron.New()
|
||||
|
||||
htmlRender := ron.HTMLRender()
|
||||
r.Renderer = htmlRender
|
||||
|
||||
r.GET("/", helloWorld)
|
||||
r.GET("/json", helloWorldJSON)
|
||||
r.POST("/another", anotherHelloWorld)
|
||||
r.GET("/html", helloWorldHTML)
|
||||
r.GET("/component", componentHTML)
|
||||
|
||||
slog.Info("Server is running at http://localhost:8080")
|
||||
http.ListenAndServe(":8080", r)
|
||||
@@ -27,5 +32,16 @@ func anotherHelloWorld(c *ron.Context) {
|
||||
}
|
||||
|
||||
func helloWorldJSON(c *ron.Context) {
|
||||
c.JSON(200, ron.D{"message": "hello world"})
|
||||
c.JSON(200, ron.Data{"message": "hello world"})
|
||||
}
|
||||
|
||||
func helloWorldHTML(c *ron.Context) {
|
||||
c.HTML(200, "page.index.gohtml", ron.Data{
|
||||
"title": "hello world",
|
||||
"message": "hello world from html",
|
||||
})
|
||||
}
|
||||
|
||||
func componentHTML(c *ron.Context) {
|
||||
c.HTML(200, "component.list.gohtml", ron.Data{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user