cloudcontext

package module
v1.0.0-...-7f80349 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

README

cloudcontext

GoDoc
Build Status
Coverage Status
License

cloudcontext adds the cloud context to the context. There are also functions for adding authenticated http.Client to the context.

Installation

The import path for the package is gopkg.in/cogger/cloudcontext.v1.

To install it, run:

go get gopkg.in/cogger/cloudcontext.v1

Usage

// main.go
package main

import (
	"log"
	"net/http"
	"gopkg.in/cogger/cogger.v1"
	"gopkg.in/cogger/cloudcontext.v1"
	"gopkg.in/cogger/cloudcontext.v1/client"
	"gopkg.in/cogger/cloudcontext.v1/bq"
	"golang.org/x/net/context"
)

func foo(ctx context.Context, w http.ResponseWriter, r *http.Request) int{
	service := bq.FromContext(ctx)
	//Do something with bigquery
	return http.StatusOK
}

func init() {
	fooHandler := cogger.NewHandler()
	fooHandler.AddContext(client.Compute, cloudcontext.Add)
	fooHandler.SetHandler(foo)

  	http.Handle("/foo", fooHandler)
  	log.Fatal(http.ListenAndServe(":8080", nil))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(projectID string) func(context.Context, *http.Request) context.Context

Add adds the cloud context to the context

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL