From 637fd8f67b7ff6191673ff13e94825a4ec896891 Mon Sep 17 00:00:00 2001 From: Jason Du Date: Fri, 30 Apr 2021 19:17:23 -0700 Subject: fileserver: Share template logic for both `templates` and `file_server browse` (#4093) Co-authored-by: Matthew Holt --- modules/caddyhttp/templates/tplcontext_test.go | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'modules/caddyhttp/templates/tplcontext_test.go') diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go index c0658a1..efee3be 100644 --- a/modules/caddyhttp/templates/tplcontext_test.go +++ b/modules/caddyhttp/templates/tplcontext_test.go @@ -12,20 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Copyright 2015 Light Code Labs, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package templates import ( @@ -357,7 +343,7 @@ title = "Welcome" } -func getContextOrFail(t *testing.T) templateContext { +func getContextOrFail(t *testing.T) TemplateContext { context, err := initTestContext() if err != nil { t.Fatalf("failed to prepare test context: %v", err) @@ -365,15 +351,15 @@ func getContextOrFail(t *testing.T) templateContext { return context } -func initTestContext() (templateContext, error) { +func initTestContext() (TemplateContext, error) { body := bytes.NewBufferString("request body") request, err := http.NewRequest("GET", "https://example.com/foo/bar", body) if err != nil { - return templateContext{}, err + return TemplateContext{}, err } - return templateContext{ + return TemplateContext{ Root: http.Dir(os.TempDir()), Req: request, - RespHeader: tplWrappedHeader{make(http.Header)}, + RespHeader: WrappedHeader{make(http.Header)}, }, nil } -- cgit v1.2.3