-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing integration test dependency on internet access
Signed-off-by: Dave Henderson <[email protected]>
- Loading branch information
1 parent
789a0d9
commit 57e270a
Showing
6 changed files
with
92 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
gomplate | ||
mirror |
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
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,50 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"flag" | ||
"log" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
// Req - | ||
type Req struct { | ||
Headers http.Header `json:"headers"` | ||
} | ||
|
||
var port string | ||
|
||
func main() { | ||
flag.StringVar(&port, "p", "8080", "Port to listen to") | ||
flag.Parse() | ||
|
||
l, err := net.Listen("tcp", ":"+port) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
// defer l.Close() | ||
http.HandleFunc("/", rootHandler) | ||
|
||
http.HandleFunc("/quit", quitHandler(l)) | ||
|
||
http.Serve(l, nil) | ||
} | ||
|
||
func rootHandler(w http.ResponseWriter, r *http.Request) { | ||
req := Req{r.Header} | ||
b, err := json.Marshal(req) | ||
if err != nil { | ||
log.Println(err) | ||
w.WriteHeader(http.StatusBadRequest) | ||
} | ||
w.Header().Set("Content-Type", "application/json") | ||
w.Write(b) | ||
} | ||
|
||
func quitHandler(l net.Listener) func(http.ResponseWriter, *http.Request) { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
l.Close() | ||
w.WriteHeader(http.StatusNoContent) | ||
} | ||
} |