Skip to content

events of json type don't have their Content-Type header set #15

@regner

Description

@regner

Sample code:

// Setup, connection handling, etc.

b := bytes.NewBufferString("event json DTMF\n")
b.WriteTo(conn)

// Some other code and then this runs in a goroutine for us

for {
    msg, err := conn.ReadMessage()

    // For JSON events this ends up being ""
    msgType := msg.GetHeader("Content-Type")

    switch msgType {
    case "text/disconnect-notice":
        done <- true
    case "text/event-plain":
        // assuming "event plain DTMF" is sent instead of JSON this will trigger
    case "text/event-json":
        // This will never trigger
    }

    //This is my current hack
    if eventName, ok := msg.Headers["Event-Name"]; ok {
        switch eventName {
        case "DTMF":
            logger.Errorf("DTMF: %s", msg.Headers["DTMF-Digit"])
        }
    }
}

Our current version of gesl:
revision = "1cd1251c682b6645e93bdc58ba48de5ed75fbd48"
version = "1.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions