router

package
v0.0.0-...-cc973eb Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractGCSPath

func ExtractGCSPath(uri string) (string, error)

ExtractGCSPath returns the path after the bucket name and gs:// scheme.

func GetBucketName

func GetBucketName(uri string) (string, error)

GetBucketName tries to obtain the bucket name. Bucket names must contain the gs:// prefix to distinguish them as being GCP type buckets.

Types

type AppError

type AppError struct {
	Error   error
	Message string
	Code    int
}

func AppErrorf

func AppErrorf(code int, msg string, err error) *AppError

type AppHandler

type AppHandler func(http.ResponseWriter, *http.Request) *AppError

func HealthCheckHandler

func HealthCheckHandler() AppHandler

HealthCheckHandler ensures the base endpoint is available and can return an HTTP status code 200

func OCRBucketDirHandler

func OCRBucketDirHandler(gCPVisionAPIServer *GCPVisionAPIServer) AppHandler

OCRBucketDirHandler performs the vision API operation on the entire bucket or dir provided

func OCRHandler

func OCRHandler(gCPVisionAPIServer *GCPVisionAPIServer) AppHandler

OCRHandler handles POST requests that represent a basic request to perform OCR. A GCS file path and output path must be provided

func (AppHandler) ServeHTTP

func (fn AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FileInfoJSON

type FileInfoJSON struct {
	// OutputURI represents the GCS URI to drop off the artifacts after processing.
	OutputURI string `json:"outputUri"`
	// OutputPath represents the internal bucket folder to use
	OutputPath string `json:"outputPath"`
	// InputURI represents the GCS URI of the data to be used
	InputURI string `json:"inputUri"`
}

FileInfoJSON represents the POST from the client detailing the URI for the client. Once processed the items will be sent to the OutputURI. Both must be specified

type GCPVisionAPIServer

type GCPVisionAPIServer struct {
	Router        *mux.Router
	StorageClient *storage.Client
}

GCPVisionAPIServer is the base server that handles all incoming requests. It is equipped with a router and a reference to Vision API

func (*GCPVisionAPIServer) Init

func (g *GCPVisionAPIServer) Init() error

Init ensures all relevant clients are called and set up before requests can begin

func (*GCPVisionAPIServer) Routes

func (g *GCPVisionAPIServer) Routes() *mux.Router

Routes returns a Handler that acts as a multiplexer. We use the gorilla.Mux router.

type Initializable

type Initializable interface {
	// Init is used to initialize a given server with clients, environment variables and any other logic
	Init() error
}

Initializable interface houses the Init method used for initializing types.

Jump to

Keyboard shortcuts

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