blob: 49de5d468fa54a3b6cd37615249d365c419e02c3 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package gitiles
import (
gitilesProto ""
var clientKey = "gitiles.client"
// GetClient returns gitilesClient from context. If not set, it panics.
func GetClient(ctx context.Context) gitilesProto.GitilesClient {
v := ctx.Value(&clientKey)
if v == nil {
panic("Client is not set, use SetClient")
return v.(gitilesProto.GitilesClient)
// SetClient stores gitilesClient in context. Useful for unit testing.
func SetClient(ctx context.Context, client gitilesProto.GitilesClient) context.Context {
return context.WithValue(ctx, &clientKey, client)