I'm trying to find a concrete example where that type is used, I can't find any on the whole internet, the documentation of the package is very advanced or doesn't give details.

It all started from trying to find an error that was "goneException" when using postToConnectionInput to a client that doesn't exist, well it's like that by default, but I thought I could find a more specific error message. That's when I got to postToConnectionOutput. How can I see it? How can I use it? Can it be used in my code example?

Note: I'm not asking about how to fix the goneException, it's an error by the way, I want to know more. Can I apply the postToConnectionOutput to my example and what would it do for me?

I mention that I don't know the language to the maximum, there are some things that I don't understand well, then I put a function that what it does is send a message to all the connected clients, everything works fine, except that I INTENTIONALLY put an ID that doesn't exist, and I would like to know if I can get more information about what happens, not just a "goneException" Can postToConnectionOutput be used, what would it be for? I also leave below the types of goolang and the associated documentation.

My code, use postToConnectionInput:
All errors: goneException (correct!) ¿I can see more with postToConnectionOutput What does postToConnectionOutput? and And how is it implemented?
https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/apigatewaymanagementapi#PostToConnectionInput

I don't understand what the function of postToConnectionOutput is and how it is implemented, I tried, I searched many places, I couldn't. Can postToConnectionOutput be applied to my code? What good would it do me? What do I do with that?

Thank you very much if someone could explain or tell me, or give me an example, or what it is for. Grateful.

func sendAll(r events.APIGatewayWebsocketProxyRequest) (interface{}, error) {
    idCon := r.RequestContext.ConnectionID
    cantidadClientes := strconv.Itoa(len(ListaClientes))
    fmt.Println("sendAll ejecutada, ID DE CONEXIÓN (emisor): ", idCon, "cantidad de clientes: ["+cantidadClientes+"]")
    mensaje := "Este es un mensaje para todos"

    mySession := session.Must(session.NewSession())
    api := apigatewaymanagementapi.New(mySession, aws.NewConfig().WithEndpoint("xxxxxxxxxxxxxxxxxxxxx"))

    for _, idcliente := range ListaClientes {
        structRes := &apigatewaymanagementapi.PostToConnectionInput{
            ConnectionId: aws.String(idcliente), 
            Data:         []byte(mensaje),
        }

        _, err := api.PostToConnection(structRes)
        if err != nil {
            fmt.Println("WARNING, sendAll(), idconexión: ["+idcliente+"]->", err, "<-")
            if awsErr, ok := err.(awserr.Error); ok {
                log.Println("Error:", awsErr.Code(), awsErr.Message())
                log.Println("Error:", awsErr)
                fmt.Println("ee: ", errors.Unwrap(awsErr))
                if origErr := errors.Unwrap(awsErr); origErr != nil {
                    fmt.Println(origErr)
                }
            }
            x := fmt.Errorf("%w", err)
            fmt.Println(x)
            fmt.Println(fmt.Printf("%v", x))
            var gne *apitypes.GoneException
            if errors.As(err, &gne) {
                log.Println("error:", gne.Error())
            }
        }

    }
    return events.APIGatewayProxyResponse{
        StatusCode: 200,
    }, nil
}

It seems that this API is used with the Amazon API Gateway Management API as per my Google search Search related to Amazon API postToConnection Output.

The 'postToConnectionOutput' function refers to the response object returned when you use the 'postToConnection' method to send data to a specific connected client.

The 'postToConnectionOutput' object contains information about the success or failure of your request, such as the status code and any error messages. It can also include additional details or metadata related to your response.

The 'postToConnectionOutput' object may vary depending on the programming language you are using, it looks like Golang but we cannot see your screen to confirm :). I recommend you to refer to the official documentation for more information on the function and its output from the supplier of the API.

Here is a small example of how it can be used -

{
  StatusCode: 200,
  Body: '',
  Headers: {
    key1: 'value1',
    key2: 'value2'
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.