Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Last active January 20, 2016 16:20
Show Gist options
  • Save hackintoshrao/f5196a023776ae50d098 to your computer and use it in GitHub Desktop.
Save hackintoshrao/f5196a023776ae50d098 to your computer and use it in GitHub Desktop.
starting caddy server from within the code as an external application with specified configuration
func TestBrowseMiddlewareForHtmlResponse(t *testing.T) {
//formulating configuration for starting Caddy.
//The configuration below is used defualt host <localhost> and default port <2015> for running the server
//browse middleware is activated
input := caddy.CaddyfileInput{
Contents: []byte(fmt.Sprintf("%s:%s\nbasicauth /protected my-username my-passworde ", caddy.DefaultHost, "2015")),
}
//starting caddy server
err := caddy.Start(input)
if err != nil {
t.Fatalf("Error starting caddy: %v", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment