Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    WladMeixner
    @WladMeixner
    Hi
    Roland Singer
    @m4ng0squ4sh
    @WladMeixner :D
    Leonardo Gago
    @ljgago
    Hi, I'm tried to run glue in my app server made with gin (http famework), I have problem with the routing inter glue and gin, do you know some form to use these combined? thanks!
    Roland Singer
    @m4ng0squ4sh
    hey :) could you create a small sample go application? I'll try to make them compatible then!
    Leonardo Gago
    @ljgago

    Hi, I already could make it work, I needed routing the handler manually

    My main.go

    glue.OnNewSocket(onSocket)
    r := gin.New()
    r.Use(gin.Logger())
    r.Use(gin.Recovery())
    r.Static("/assets", "./client")
    r.GET("/", func(c *gin.Context) {
        c.File("./client/views/index.html")
    })
    // Routing manually
    rs := r.Group("/glue")
    rs.GET("/ws", func(c *gin.Context) {
      glue.HandleWebSocket(c.Writer, c.Request)
    })
    rs.POST("/ajax", func(c *gin.Context) {
      glue.HandleAjaxSocket(c.Writer, c.Request)
    })
    r.Run(":3000") // Port

    I mod the glue functions:

    backend/websocket.go

    /*func init() {
        // Create the websocket handler
        http.HandleFunc(httpWebSocketURL, handleWebSocket)
    }*/
    
    /*func handleWebSocket(w http.ResponseWriter, req *http.Request) {
    ...
    }*/
    
    func HandleWebSocket(w http.ResponseWriter, req *http.Request) {
    ...
    }

    backend/ajaxsocket.go

    /*func init() {
        // Create the ajax socket handler.
        http.HandleFunc(httpAjaxSocketURL, handleAjaxSocket)
    }*/
    ...
    /*func handleAjaxSocket(w http.ResponseWriter, req *http.Request) {
    ...
    }*/
    func HandleAjaxSocket(w http.ResponseWriter, req *http.Request) {
    ...
    }

    and add:
    socket.go

    func HandleAjaxSocket(w http.ResponseWriter, req *http.Request) {
        backend.HandleAjaxSocket(w, req)
    }
    
    func HandleWebSocket(w http.ResponseWriter, req *http.Request) {
        backend.HandleWebSocket(w, req)
    }
    Roland Singer
    @m4ng0squ4sh
    @ljgago Please check the new glue 1.3.0 version. It adds support for custom multiplexers
    https://github.com/desertbit/glue#use-a-custom-http-multiplexer
    Be aware, that the are some minor syntax changes... :)