server.go 869 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package manager
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. )
  6. type worker struct {
  7. // worker name
  8. name string
  9. // url to connect to worker
  10. url string
  11. // session token
  12. token string
  13. }
  14. func makeHTTPServer(debug bool) *gin.Engine {
  15. if !debug {
  16. gin.SetMode(gin.ReleaseMode)
  17. }
  18. r := gin.Default()
  19. r.GET("/ping", func(c *gin.Context) {
  20. c.JSON(http.StatusOK, gin.H{"msg": "pong"})
  21. })
  22. // list jobs, status page
  23. r.GET("/jobs", func(c *gin.Context) {})
  24. // worker online
  25. r.POST("/workers/:name", func(c *gin.Context) {})
  26. // get job list
  27. r.GET("/workers/:name/jobs", func(c *gin.Context) {})
  28. // post job status
  29. r.POST("/workers/:name/jobs/:job", func(c *gin.Context) {})
  30. // worker command polling
  31. r.GET("/workers/:name/cmd_stream", func(c *gin.Context) {})
  32. // for tunasynctl to post commands
  33. r.POST("/cmd/", func(c *gin.Context) {})
  34. return r
  35. }