Contains the Concourse pipeline definition for building a line-server container
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
510 B

  1. package main
  2. import (
  3. "net/http"
  4. "strings"
  5. )
  6. type addheaders struct {
  7. h http.Handler
  8. headers []string
  9. }
  10. func (a addheaders) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  11. for _, header := range a.headers {
  12. headerSplit := strings.SplitN(header, ": ", 2)
  13. w.Header().Add(headerSplit[0], headerSplit[1])
  14. }
  15. a.h.ServeHTTP(w, r)
  16. }
  17. func AddHeaders(headers []string) func(http.Handler) http.Handler {
  18. fn := func(h http.Handler) http.Handler {
  19. return addheaders{h, headers}
  20. }
  21. return fn
  22. }