backend

package
v0.0.0-...-7faa966 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppHandler

type AppHandler func(*http.Request) (rsp *Response)

AppHandler helps generalize http responses

func (AppHandler) ServeHTTP

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

type Backender

type Backender interface {
	Setup() (err error)
	// contains filtered or unexported methods
}

Backender outlines methods to store and retrieve saved commands

type Config

type Config struct {
	Backender
	Encrypt   crypto.Encryptor
	Decrypt   crypto.Decryptor
	JWTSecret string
	Key       string
	UserFn    func(email string, commandNumber int) error
}

Config holds configuration settings for the api

func (*Config) GetHandler

func (cfg *Config) GetHandler(r *http.Request) (rsp *Response)

GetHandler returns a user's commands curl 'http://127.0.0.1:8000/get?google_key=my_key'

func (*Config) RegisterUserHandler

func (cfg *Config) RegisterUserHandler(r *http.Request) (rsp *Response)

func (*Config) RunHandler

func (cfg *Config) RunHandler(r *http.Request) (rsp *Response)

RunHandler runs a single, named command curl -XPOST 'http://127.0.0.1:8000/run' -d '{"google_key":"my_key", "command_name":"curl_command", "params":["1"]}'

func (*Config) RunSheetsHandler

func (cfg *Config) RunSheetsHandler(r *http.Request) (rsp *Response)

RunSheetsHandler runs a single command (for Google Sheets) curl -XPOST 'http://127.0.0.1:8000/sheets_run' -d '{"command_number":2, "params":["123"], "email":"me@example.com", "command":{"name":"my command","filter":{"type":"jmespath","filter":{"expression":""}},"command":{"type":"direct","command":{"method":"get","url":"https://example.com"}}},"key":"1234567"}'

func (*Config) SaveHandler

func (cfg *Config) SaveHandler(r *http.Request) (rsp *Response)

SaveHandler saves a user's commands curl -XPOST 'http://127.0.0.1:8000/save' -d '{"google_key":"my_key","commands":[{"name":"api_command","command":{"type":"direct","command":{"method":"get","url":"https://api.chucknorris.io/jokes/random", "headers":[{"key":"User-Agent","value":"Data Connector"}]}},"filter":{"type":"jmespath","filter":{"expression":"[[value]]"}}}]}'

func (*Config) UpdateGoogleKeyHandler

func (cfg *Config) UpdateGoogleKeyHandler(r *http.Request) (rsp *Response)

UpdateGoogleKeyHandler updates a user's Google Sheets API Key

type PostgreSQL

type PostgreSQL struct {
	*sql.DB
}

PostgreSQL holds settings for a PostgreSQL database

func (*PostgreSQL) Setup

func (p *PostgreSQL) Setup() (err error)

Setup creates our tables

type Response

type Response struct {
	Status      int         `json:"-"`
	Template    string      `json:"-"`
	Response    interface{} `json:"response,omitempty"`
	Error       error       `json:"-"`
	ErrorString string      `json:"error,omitempty"`
}

Response is the http response to a request

type User

type User struct {
	Email string `json:"email"`
}

User is a registered user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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