Skip to content

Commit

Permalink
feat: support extra headder
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiningRush committed Mar 15, 2023
1 parent 8993ec7 commit 940bc4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mock:
.PHONY: tidy
tidy:
go mod tidy && go fmt ./...
$(foreach var,$(WRAPPER_SUBMODULES),cd $(PWD)/wrapper/$(var) && go mod tidy && go fmt ./...;)
@$(foreach var,$(WRAPPER_SUBMODULES),cd $(PWD)/wrapper/$(var) && go mod tidy && go fmt ./...;)

.PHONY: test
test:
Expand Down
2 changes: 2 additions & 0 deletions data/resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type FileResponse struct {
ContentReader io.ReadCloser
Size int
StatusCode int

ExtraHeader map[string]string
}

func (r *FileResponse) Get() *FileResponse {
Expand Down
5 changes: 5 additions & 0 deletions wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func writeFileResp(input HandleHttpInPipelineInput, fr data.HttpFileResponse) {
if fileResp.Size != 0 {
input.RespWriter.SetHeader("Content-Length", strconv.Itoa(fileResp.Size))
}
if fileResp.ExtraHeader != nil {
for k, v := range fileResp.ExtraHeader {
input.RespWriter.SetHeader(k, v)
}
}

if fileResp.ContentReader != nil {
if sw, ok := input.RespWriter.(data.StreamSetter); ok {
Expand Down

0 comments on commit 940bc4d

Please sign in to comment.