Skip to content

Failing to write a response containing headers #161

@DonRichie

Description

@DonRichie

Hello,

I am currently trying to create a response containing headers in openwhisk with golang.
I feel like I need a nested map with different value types. But since golang is strongly-typed that is impossible.
I tried to marshal a struct, but failed since the Main functions wants a map as return value.

My best try as response is:

  outobj := make(map[string]interface{})
  outobj["headers"] = "{\"Content-Type\": \"text/html\"}"
  outobj["statusCode"] = 201
  outobj["body"] = "123"
  return outobj

But invoking that action gives an http error.
The reason for that error is the content of the "headers" key. Uncommenting it makes the action work.

Can someone provide an example how to set headers in the golang response?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions