-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlers.go
41 lines (35 loc) · 841 Bytes
/
handlers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func Index(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, "https://github.com/notarun/isrss")
}
func AllNews(c *gin.Context) {
result, err := GetResults(ALL_NEWS)
if err != nil {
c.Error(err)
c.String(http.StatusBadGateway, err.Error())
return
}
c.XML(http.StatusOK, NewRSS(result, "Inshorts: All"))
}
func Trending(c *gin.Context) {
result, err := GetResults(TRENDING_NEWS)
if err != nil {
c.Error(err)
c.String(http.StatusBadGateway, err.Error())
return
}
c.XML(http.StatusOK, NewRSS(result, "Inshorts: Trending"))
}
func TopStories(c *gin.Context) {
result, err := GetResults(TOP_NEWS)
if err != nil {
c.Error(err)
c.String(http.StatusBadGateway, err.Error())
return
}
c.XML(http.StatusOK, NewRSS(result, "Inshorts: Top"))
}