gofireprox

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

GoFireProx

This is a port of FireProx to Golang

Installation

go install -v github.com/mr-pmillz/gofireprox/cmd/gofireprox@latest

gofireprox as library

Integrate gofireprox with other go programs

package main

import (
	"fmt"
	"github.com/mr-pmillz/gofireprox"
)

func main() {
	region := "us-east-1"
	
	fpClient, err := gofireprox.NewFireProx(&gofireprox.FireProxOptions{
		AccessKey:       "CHANGEME",
		SecretAccessKey: "CHANGEME",
		Region:          region,
		URL:             "https://ifconfig.me",
	})
	if err != nil {
		panic(err)
	}
	
	apiID, proxyURL, err := fpClient.CreateAPI()
	if err != nil {
		panic(err)
	}
	// use the proxyURL for your requests as you would normally with an http.Client. See FireProx Docs for headers etc. X-My-X-Forwarded-For: etc...
	// DoWork...
	// Delete API
	successful := fpClient.DeleteAPI(apiID)
	var success string
	if successful {
		success = "Success!"
	} else {
		success = "Failed!"
	}
	fmt.Printf("Deleting %s => %s\n", apiID, success)
}

Credits

Documentation

Index

Constants

View Source
const CurrentVersion = `v0.1.6`

Variables

This section is empty.

Functions

This section is empty.

Types

type APICache added in v0.1.4

type APICache struct {
	Data  map[string]RegionCache
	Mutex sync.Mutex
}

type FireProx

type FireProx struct {
	Options *FireProxOptions
	Client  *apigateway.Client
	Cache   APICache
}

func NewFireProx

func NewFireProx(opts *FireProxOptions) (*FireProx, error)

NewFireProx ...

func (*FireProx) Cleanup

func (fp *FireProx) Cleanup()

Cleanup ...

func (*FireProx) CreateAPI

func (fp *FireProx) CreateAPI() (string, string, error)

CreateAPI ...

func (*FireProx) DeleteAPI

func (fp *FireProx) DeleteAPI(apiID string) bool

DeleteAPI directly deletes the apiID without confirming the apiID's existence first this helps to reduce api calls that can quickly exceed the quota it returns true if successful, false if err

func (*FireProx) IfExistsDeleteAPI added in v0.1.4

func (fp *FireProx) IfExistsDeleteAPI(apiID string) bool

IfExistsDeleteAPI ...

func (*FireProx) InvalidateCache added in v0.1.4

func (fp *FireProx) InvalidateCache(region string)

InvalidateCache clears the cached data for a specific region

func (*FireProx) ListAPIs

func (fp *FireProx) ListAPIs() ([]types.RestApi, error)

ListAPIs ...

func (*FireProx) UpdateAPI

func (fp *FireProx) UpdateAPI(apiID, apiURL string) (bool, error)

UpdateAPI ...

type FireProxOptions

type FireProxOptions struct {
	AccessKey       string
	SecretAccessKey string
	SessionToken    string
	Profile         string
	Region          string
	Command         string
	APIID           string
	URL             string
	Verbose         bool
	Version         bool
	CacheDuration   time.Duration
}

type RegionCache added in v0.1.4

type RegionCache struct {
	APIs      []types.RestApi
	Timestamp time.Time
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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