arbor

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: NCSA Imports: 9 Imported by: 3

README

alt tag Build Status GoDoc Go Report Card

Arbor is a statically configured framework for creating API Gateways. It provides the following capabilities:

  • Easy registration of services
  • Basic application authorization and request sanitization
  • Proxying API calls
  • Managing inter-service communication

Arbor supports JSON APIs with support for others coming soon. When registering as service specify the data encoding and when requesting a resource though groot make the request using json.

Registering Services

Add the API spec in a new file (ex. todo.go) in the services package

There is a set of proxy api calls defined in the proxy package that will route call to the backend services

AS OF 10/28/15

/**
 *  Pass the http Request from the client and the ResponseWriter it expects
 *  Pass the target url of the backend service (not the url the client called)
 *  Pass the format of the service
 *  Pass a authorization token (optional)
 *  Will call the service and return the result to the client.
 **/
 func GET(w http.ResponseWriter, url string, format string, token string, r *http.Request)
 /**
  *  Pass the http Request from the client and the ResponseWriter it expects
  *  Pass the target url of the backend service (not the url the client called)
  *  Passes the encoded json(only format currently supported) to the service.
  *  Pass a authorization token (optional)
  *  Will call the service and return the result to the client.
  **/
  func POST(w http.ResponseWriter, url string, format string, token string, r *http.Request)
 /**
  *  Pass the http Request from the client and the ResponseWriter it expects
  *  Pass the target url of the backend service (not the url the client called)
  *  Passes the encoded json(only format currently supported) to the service.
  *  Pass a authorization token (optional)
  *  Will call the service and return the result to the client.
  **/
  func PUT(w http.ResponseWriter, url string, format string, token string, r *http.Request)
/**
 *  Pass the http Request from the client and the ResponseWriter it expects
 *  Pass the target url of the backend service (not the url the client called)
 *  Pass a authorization token (optional)
 *  Will call the service and return the result to the client.
 **/
 func DELETE(w http.ResponseWriter, url string, format string, token string, r *http.Request)

All secret data should be kept in a file called config.go in the config directory

Install

Minimum supported version is Go 1.8

go get -u github.com/arbor-dev/arbor/...

run the server

go run ./server/*.go

compile the service

go build -o groot [PATH TO GROOT]/server

CLI

groot [-r | --register-client client_name] [-c | --check-registration token] [-u | --unsecured]

-r | --register-client client_name

registers a client, generates a token

-c | --check-registration token

checks if a token is valid and returns name of client

-u | --unsecured

runs groot without the security layer

-l | --list-clients

lists all registered client names

-d | --delete-client client_name

deletes the client token with the given name

without args

runs groot with the security layer

License

This project is licensed under the University of Illinois/NCSA Open Source License. For a full copy of this license take a look at the LICENSE file.

When contributing new files to this project, preappend the following header to the file as a comment:

Copyright © 2017, ACM@UIUC

This file is part of the Groot Project.  
 
The Groot Project is open source software, released under the University of Illinois/NCSA Open Source License. 
You should have received a copy of this license in a file with the distribution.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Boot

func Boot(routes RouteCollection, addr string, port uint16) *server.ArborServer

Boot is a standard server CLI

Provide a set of routes to serve and a port to serve on.

Usage: executable [-r | --register-client client_name] [-c | --check-registration token] [-u | --unsecured]

-r | --register-client client_name

registers a client, generates a token

-c | --check-registration token

checks if a token is valid and returns name of client

-u | --unsecured

runs arbor without the security layer

	-l | --list-clients
 lists all registered client names

	-d | --delete-client client_name
 deletes the client token with the given name

	without args

runs arbor with the security layer

It will start the arbor instance, parsing the command arguments and execute the behavior.

func CheckRegistration

func CheckRegistration(token string)

CheckRegistration allows you to check what client was assigned to a particular token

func DELETE

func DELETE(w http.ResponseWriter, url string, format string, token string, r *http.Request)

DELETE provides a proxy DELETE request allowing authorized clients to make DELETE requests of the microservices

Pass the http Request from the client and the ResponseWriter it expects.

Pass the target url of the backend service (not the url the client called).

Pass the format of the service.

Pass a authorization token (optional).

Will call the service and return the result to the client.

func DeleteClient

func DeleteClient(name string)

func GET

func GET(w http.ResponseWriter, url string, format string, token string, r *http.Request)

GET provides a proxy GET request allowing authorized clients to make GET requests of the microservices

Pass the http Request from the client and the ResponseWriter it expects.

Pass the target url of the backend service (not the url the client called).

Pass the format of the service.

Pass a authorization token (optional).

Will call the service and return the result to the client.

func ListClients

func ListClients()

func PATCH

func PATCH(w http.ResponseWriter, url string, format string, token string, r *http.Request)

PATCH provides a proxy PATCH request allowing authorized clients to make PATCH requests of the microservices

Pass the http Request from the client and the ResponseWriter it expects.

Pass the target url of the backend service (not the url the client called).

Pass the format of the service.

Pass a authorization token (optional).

Will call the service and return the result to the client.

func POST

func POST(w http.ResponseWriter, url string, format string, token string, r *http.Request)

POST provides a proxy POST request allowing authorized clients to make POST requests of the microservices

Pass the http Request from the client and the ResponseWriter it expects.

Pass the target url of the backend service (not the url the client called).

Pass the format of the service.

Pass a authorization token (optional).

Will call the service and return the result to the client.

func PUT

func PUT(w http.ResponseWriter, url string, format string, token string, r *http.Request)

PUT provides a proxy PUT request allowing authorized clients to make PUT requests of the microservices

Pass the http Request from the client and the ResponseWriter it expects.

Pass the target url of the backend service (not the url the client called).

Pass the format of the service.

Pass a authorization token (optional).

Will call the service and return the result to the client.

func RegisterClient

func RegisterClient(name string)

RegisterClient will generate a access token for a client

Currently uses a db of client names.

Types

type Route

type Route struct {
	Name    string           `json:"Name"`
	Method  string           `json:"Method"`
	Pattern string           `json:"Pattern"`
	Handler http.HandlerFunc `json:"Handler"`
}

Route is a struct that defines a route for a microservice

Name: Name of the route.

Method: The type of request (GET, POST, DELETE, etc.).

Pattern: The exposed url pattern for clients to hit, allows for url encoded variables to be specified with {VARIABLE}.

HandlerFunc: The function to handle the request, this basicically should just be the proxy call, but it allows you to specify more specific things.

type RouteCollection

type RouteCollection []Route

RouteCollection is a slice of routes that is used to represent a service (may change name here)

Usage: The recomendation is to create a RouteCollection variable for all of you services and for each service create a specific one then in a registration function append all the service collections into the single master collection.

func (RouteCollection) ToServiceRoutes

func (routes RouteCollection) ToServiceRoutes() services.RouteCollection

Jump to

Keyboard shortcuts

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