Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
owenthereal committed Oct 2, 2023
1 parent 5597159 commit 7926fa4
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions caddy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func (c *caddyServer) loadConfig() (*caddy.Config, error) {
func (c *caddyServer) buildConfig(apps []candy.App) *caddy.Config {
httpServer := &caddyhttp.Server{
Routes: caddyRoutes(
reverseproxy.HTTPTransport{},
apps,
),
Listen: []string{c.cfg.HTTPAddr},
Expand All @@ -168,14 +167,7 @@ func (c *caddyServer) buildConfig(apps []candy.App) *caddy.Config {
}

httpsServer := &caddyhttp.Server{
TLSConnPolicies: []*caddytls.ConnectionPolicy{
{
// Prefer http 1.1 over h2 in order: https://github.com/caddyserver/caddy/blob/792fca40f18b7c528b00a7dea508bdfd0821dd8c/modules/caddytls/connpolicy.go#L484
ALPN: []string{"http/1.1", "h2"},
},
},
Routes: caddyRoutes(
reverseproxy.HTTPTransport{},
apps,
),
Listen: []string{c.cfg.HTTPSAddr},
Expand Down Expand Up @@ -322,12 +314,12 @@ func appHosts(apps []candy.App) []string {
return hosts
}

func caddyRoutes(tr reverseproxy.HTTPTransport, apps []candy.App) []caddyhttp.Route {
func caddyRoutes(apps []candy.App) []caddyhttp.Route {
var routes caddyhttp.RouteList

for _, app := range apps {
handler := reverseproxy.Handler{
TransportRaw: caddyconfig.JSONModuleObject(tr, "protocol", "http", nil),
TransportRaw: caddyconfig.JSONModuleObject(reverseproxy.HTTPTransport{}, "protocol", "http", nil),
Upstreams: reverseproxy.UpstreamPool{{Dial: app.Addr}},
}
route := caddyhttp.Route{
Expand Down

0 comments on commit 7926fa4

Please sign in to comment.