added check on Accept request header
This commit is contained in:
parent
fc4b4cc2e6
commit
3e23f7e872
@ -19,11 +19,16 @@ func (p *Page) GetContent(c echo.Context) (err error) {
|
||||
// Process returns main webpage or a JSON
|
||||
func (p *Page) Process(c echo.Context, querytype string) (err error) {
|
||||
p.GetContent(c)
|
||||
if querytype != "json" {
|
||||
return c.Render(http.StatusOK, "index.html", p)
|
||||
}
|
||||
if querytype == "json" {
|
||||
return c.JSONPretty(http.StatusOK, p.IP, " ")
|
||||
}
|
||||
if accept, ok := c.Request().Header["Accept"]; ok {
|
||||
if accept[0] == "*/*" {
|
||||
return c.JSONPretty(http.StatusOK, p.IP, " ")
|
||||
}
|
||||
}
|
||||
return c.Render(http.StatusOK, "index.html", p)
|
||||
}
|
||||
|
||||
// Page defines Web page
|
||||
type Page struct {
|
||||
|
Loading…
Reference in New Issue
Block a user