summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-03-26 19:42:52 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-03-26 19:42:52 -0600
commita8dc73b4d9db5edf85e78314c9759b9d12a79b71 (patch)
treec1283aa94e2b2d605985130cdef070a24d03815e /modules
parent86e2d1b0a48fbd84590291969611f1870471c3e0 (diff)
Performance testing Load function
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/caddyhttp.go21
-rw-r--r--modules/caddyhttp/caddyhttp_test.go8
2 files changed, 21 insertions, 8 deletions
diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go
index 99efef0..ec2637a 100644
--- a/modules/caddyhttp/caddyhttp.go
+++ b/modules/caddyhttp/caddyhttp.go
@@ -1,6 +1,7 @@
package caddyhttp
import (
+ "context"
"fmt"
"log"
"net"
@@ -24,13 +25,15 @@ func init() {
type httpModuleConfig struct {
Servers map[string]httpServerConfig `json:"servers"`
+
+ servers []*http.Server
}
func (hc *httpModuleConfig) Run() error {
- fmt.Printf("RUNNING: %#v\n", hc)
+ // fmt.Printf("RUNNING: %#v\n", hc)
for _, srv := range hc.Servers {
- s := http.Server{
+ s := &http.Server{
ReadTimeout: time.Duration(srv.ReadTimeout),
ReadHeaderTimeout: time.Duration(srv.ReadHeaderTimeout),
}
@@ -53,11 +56,21 @@ func (hc *httpModuleConfig) Run() error {
return nil
}
+func (hc *httpModuleConfig) Cancel() error {
+ for _, s := range hc.servers {
+ err := s.Shutdown(context.Background()) // TODO
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
func parseListenAddr(a string) (proto string, addrs []string, err error) {
proto = "tcp"
- if idx := strings.Index(a, ":::"); idx >= 0 {
+ if idx := strings.Index(a, "/"); idx >= 0 {
proto = strings.ToLower(strings.TrimSpace(a[:idx]))
- a = a[idx+3:]
+ a = a[idx+1:]
}
var host, port string
host, port, err = net.SplitHostPort(a)
diff --git a/modules/caddyhttp/caddyhttp_test.go b/modules/caddyhttp/caddyhttp_test.go
index c65a9a2..610a5f0 100644
--- a/modules/caddyhttp/caddyhttp_test.go
+++ b/modules/caddyhttp/caddyhttp_test.go
@@ -28,22 +28,22 @@ func TestParseListenerAddr(t *testing.T) {
expectAddrs: []string{":1234"},
},
{
- input: "tcp::::1234",
+ input: "tcp/:1234",
expectProto: "tcp",
expectAddrs: []string{":1234"},
},
{
- input: "tcp6::::1234",
+ input: "tcp6/:1234",
expectProto: "tcp6",
expectAddrs: []string{":1234"},
},
{
- input: "tcp4:::localhost:1234",
+ input: "tcp4/localhost:1234",
expectProto: "tcp4",
expectAddrs: []string{"localhost:1234"},
},
{
- input: "unix:::localhost:1234-1236",
+ input: "unix/localhost:1234-1236",
expectProto: "unix",
expectAddrs: []string{"localhost:1234", "localhost:1235", "localhost:1236"},
},