osin-datastore

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: MIT

README

osin-datastore

CircleCI GoDoc MIT License

A Google Cloud Datstore storage for RangelReale/osin.

This storage can be used on Google App Engine, Google Compute Engine, Googke Kubernetes Engine, On-premises environment and so on.

Install

$ go get -u github.com/ryutah/osin-datastore/v1

Usage

Google App Engine (Standard Edition)
package main

import (
	"net/http"

	"google.golang.org/appengine"

	"github.com/RangelReale/osin"
	"github.com/ryutah/osin-datastore/v1"
)

func init() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		ctx := appengine.NewContext(r)
		storage, err := datastore.NewStorageForGAE(ctx)
		if err != nil {
			http.Error(w, "failed to initialize storage client", http.StatusInternalServerError)
			return
		}
		defer storage.Close()

		server := osin.NewServer(osin.NewServerConfig(), storage)

        // do sometihng.
    }
}
Other Platforms
package main

import (
	"net/http"

	"github.com/RangelReale/osin"
	"github.com/ryutah/osin-datastore/v1"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		storage, err := datastore.NewStorage(r.Context())
		if err != nil {
			http.Error(w, "failed to initialize storage client", http.StatusInternalServerError)
			return
		}
		defer storage.Close()

		server := osin.NewServer(osin.NewServerConfig(), storage)

        // do sometihng.
    }

	http.ListenAndServe(":8080", nil)
}

Full Examples

Directories

Path Synopsis
example
Package datastore is osin storage plugin for Google Cloud Datastore
Package datastore is osin storage plugin for Google Cloud Datastore

Jump to

Keyboard shortcuts

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