Commit 36e8b969 authored by mohamad.alturky's avatar mohamad.alturky

adding rest server

parent 6af138a7
......@@ -3,7 +3,7 @@ package main
import Presentation "data_broker/server"
func main() {
server := Presentation.Server{}
server := Presentation.RestfulServer{}
server.Init()
server.MapRoutes()
server.Start("localhost:5898")
......
......@@ -7,20 +7,20 @@ import (
"github.com/gin-gonic/gin"
)
type Server struct {
type RestfulServer struct {
engine gin.Engine
}
func (server *Server) Init() {
func (server *RestfulServer) Init() {
server.engine = *gin.Default()
}
func (server *Server) MapRoutes() {
func (server *RestfulServer) MapRoutes() {
server.engine.GET("/channels/:channel", ChannelsRoutes.Pull)
server.engine.GET("/data/:channel/:key", DataRoutes.Pull)
server.engine.POST("/data/push", DataRoutes.Push)
}
func (server *Server) Start(url string) {
func (server *RestfulServer) Start(url string) {
server.engine.Run(url)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment