2017-03-08 21:38:01 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/labstack/echo"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
port string
|
|
|
|
logPath string
|
|
|
|
}
|
|
|
|
|
2017-03-10 18:09:13 +01:00
|
|
|
func NewServer(port string, logPath string) Server {
|
2017-03-08 21:38:01 +01:00
|
|
|
return Server{
|
|
|
|
port: port,
|
|
|
|
logPath: logPath,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) Init() {
|
|
|
|
|
|
|
|
e := echo.New()
|
2017-03-10 18:09:13 +01:00
|
|
|
|
2017-03-08 21:38:01 +01:00
|
|
|
e.GET("/", func(c echo.Context) error {
|
|
|
|
return c.String(http.StatusOK, "Hello, World!")
|
|
|
|
})
|
|
|
|
e.GET("/channel/:channel/user/:username", s.getCurrentChannelLogs)
|
|
|
|
e.GET("/channel/:channel/user/:username/:year/:month", s.getDatedChannelLogs)
|
|
|
|
e.GET("/channel/:channel/user/:username/random", s.getRandomQuote)
|
|
|
|
|
2017-03-10 18:09:13 +01:00
|
|
|
e.Logger.Fatal(e.Start("127.0.0.1:" + s.port))
|
2017-03-08 21:38:01 +01:00
|
|
|
}
|