-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added a simple hello world service for testing
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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,20 @@ | ||
package vproxy | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
// StartHello world service on the given host/port | ||
// | ||
// This is a simple service which always responds with 'Hello World'. | ||
// It's mainly here to serve as a simple demo of vproxy's abilities (see readme). | ||
func StartHello(host string, port int) error { | ||
fmt.Printf("~> starting vproxy hello service at http://%s:%d\n", host, port) | ||
return http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), http.HandlerFunc(helloHandler)) | ||
} | ||
|
||
func helloHandler(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(200) | ||
fmt.Fprintf(w, "<h1>Hello World!</h1>") | ||
} |