-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add outbound http to same app tinygo example
Signed-off-by: Michelle Dhanani <michelle@fermyon.com>
- Loading branch information
Showing
7 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
examples/http-tinygo-outbound-http/outbound-http-to-same-app/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module outbound-http-to-same-app | ||
|
||
go 1.17 | ||
|
||
require github.com/fermyon/spin/sdk/go v0.0.0 | ||
|
||
require github.com/julienschmidt/httprouter v1.3.0 // indirect | ||
|
||
replace github.com/fermyon/spin/sdk/go v0.0.0 => ../../../sdk/go/ |
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
examples/http-tinygo-outbound-http/outbound-http-to-same-app/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
spinhttp "github.com/fermyon/spin/sdk/go/http" | ||
) | ||
|
||
func init() { | ||
spinhttp.Handle(func(w http.ResponseWriter, r *http.Request) { | ||
resp, err := spinhttp.Get("/hello") | ||
if err != nil { | ||
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
fmt.Fprintln(w, resp.Body) | ||
fmt.Fprintln(w, resp.Header.Get("content-type")) | ||
}) | ||
} | ||
|
||
func main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= | ||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= |
File renamed without changes.