1
0
mirror of https://github.com/rancher/norman.git synced 2025-06-22 05:27:22 +00:00
norman/api/writer/headers.go

31 lines
735 B
Go
Raw Permalink Normal View History

2017-12-30 02:14:24 +00:00
package writer
2017-11-11 04:44:02 +00:00
import (
"github.com/rancher/norman/api/builtin"
"github.com/rancher/norman/types"
)
2017-12-30 02:14:24 +00:00
func AddCommonResponseHeader(apiContext *types.APIContext) error {
2017-11-11 04:44:02 +00:00
addExpires(apiContext)
return addSchemasHeader(apiContext)
}
func addSchemasHeader(apiContext *types.APIContext) error {
schema := apiContext.Schemas.Schema(&builtin.Version, "schema")
if schema == nil {
return nil
}
2018-01-30 23:49:37 +00:00
version := apiContext.SchemasVersion
if version == nil {
version = apiContext.Version
}
apiContext.Response.Header().Set("X-Api-Schemas", apiContext.URLBuilder.Collection(schema, version))
2017-11-11 04:44:02 +00:00
return nil
}
func addExpires(apiContext *types.APIContext) {
apiContext.Response.Header().Set("Expires", "Wed 24 Feb 1982 18:42:00 GMT")
}