You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/08/23 15:50:29 UTC

[GitHub] [openwhisk-runtime-go] rabbah edited a comment on issue #102: Custom http status after function invocation

rabbah edited a comment on issue #102: Custom http status after function invocation
URL: https://github.com/apache/openwhisk-runtime-go/issues/102#issuecomment-524365660
 
 
   As with all `webactions` you can set the statusCode property on the response.
   
   ```
   > cat hello.go
   package main
   
   func Main(args map[string]interface{}) map[string]interface{} {
   	name, ok := args["name"].(string)
   	if !ok {
   		name = "stranger"
   	}
   	msg := make(map[string]interface{})
   	msg["body"] = "Hello, " + name + "!"
   	msg["statusCode"] = 201
   	return msg
   }
   ```
   
   you can create the action as any other action and turn it into a web action for API calls;
   ```
   > wsk action create hello hello.go --web true
   ```
   
   then test the url with curl and see the response code is 201 in this case.
   
   See docs here https://github.com/apache/openwhisk/blob/master/docs/webactions.md#handling-http-requests-with-actions.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services