How can I make content in the form of 4 titles and 4 lists with go rest api gin framework?
For example, there is a job posting on a page, when you click on the title of the job posting, it will direct you to the detail page and 4 content will be in the form of 4 titles. How can I do this?
type Job struct {
ID int `db:"id" json:"id"`
Title string `db:"title" json:"title"`
Body string `db:"body" json:"body"`
Date time.Time `db:"date" json:"date"`
}
Master > Details can be done in many ways. Here is my approach. I discovered a technique that writes the page to the buffer and then fetched into innerHTML by Javascript. By using this technique the detailed page is updated with minimal flickering.
// write card to desk
func get_card(w http.ResponseWriter, module string, mode string, val string) {
page := module + "_" + mode + ".html"
data := json2map4id(module, val)
var buf bytes.Buffer
tpl.ExecuteTemplate(&buf, page, data)
fmt.Fprint(w, buf.String())
}
Basically you can do a normal html template using lists, divs or other common html stuff. Populating the list (or whatever) by using JSON into the html template.