Files
ziti/controller/response/headers.go
T
Andrew Martinez df1f2a1a75 fixes #497 send session header
- add server headers during HTTP handler delegation rather than at HTTP
  response time
- remove all old header setting locations
- remove unused status writer and other response code
- add manual set on authentication for session headers
2021-02-01 14:28:29 -05:00

44 lines
1.3 KiB
Go

/*
Copyright NetFoundry, Inc.
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
https://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 response
import (
"github.com/openziti/edge/build"
"strconv"
)
const (
ApiSessionExpirationSecondsHeader = "expiration-seconds"
ApiSessionExpiresAtHeader = "expires-at"
ServerHeader = "server"
)
func AddHeaders(rc *RequestContext) {
buildInfo := build.GetBuildInfo()
if buildInfo != nil {
rc.ResponseWriter.Header().Set(ServerHeader, "ziti-controller/"+buildInfo.Version())
}
AddSessionHeaders(rc)
}
func AddSessionHeaders(rc *RequestContext) {
if rc.ApiSession != nil {
rc.ResponseWriter.Header().Set(ApiSessionExpirationSecondsHeader, strconv.FormatInt(int64(rc.ApiSession.ExpirationDuration.Seconds()), 10))
rc.ResponseWriter.Header().Set(ApiSessionExpiresAtHeader, rc.ApiSession.ExpiresAt.String())
}
}