@@ -32,6 +32,7 @@ func main() {
3232 http .HandleFunc ("/servicebindingroot" , serviceBindingRootHandler )
3333 http .HandleFunc ("/servicebindings" , serviceBindingsHandler )
3434 http .HandleFunc ("/exit" , exitHandler )
35+ http .HandleFunc ("/outbound" , outboundHandler )
3536 http .HandleFunc ("/log" , logHandler )
3637
3738 port := os .Getenv ("PORT" )
@@ -86,6 +87,21 @@ func helloWorldHandler(arg string) func(w http.ResponseWriter, _ *http.Request)
8687 }
8788}
8889
90+ func outboundHandler (w http.ResponseWriter , _ * http.Request ) {
91+ client := & http.Client {
92+ Timeout : 2 * time .Second ,
93+ }
94+ resp , err := client .Get ("http://google.com/" )
95+ if err != nil {
96+ http .Error (w , fmt .Sprintf ("Failed to make outbound request: %v" , err ), http .StatusBadRequest )
97+ return
98+ }
99+ defer resp .Body .Close ()
100+ w .WriteHeader (http .StatusOK )
101+ fmt .Fprintln (w , "Outbound request to google.com was successful" )
102+ fmt .Fprintln (w , "Response status code:" , resp .StatusCode )
103+ }
104+
89105func envJsonHandler (w http.ResponseWriter , _ * http.Request ) {
90106 envJson := map [string ]string {}
91107 env := os .Environ ()
0 commit comments