api

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusError = "ERROR"
	StatusOk    = "OK"
)

Variables

View Source
var AccessKeyTypeAdmin = AccessKeyType{Type: "admin"}
View Source
var AccessKeyTypeInvoice = AccessKeyType{Type: "invoice"}
View Source
var AccessKeyTypeNone = AccessKeyType{Type: "none"} // no authorization required
View Source
var AuthTypeBasic = AuthType{Type: "Basic"}
View Source
var AuthTypeBearerBase64 = AuthType{Type: "Bearer", Decoder: base64.StdEncoding.DecodeString}
View Source
var AuthTypeNone = AuthType{}

Functions

func AuthorizationMiddleware

func AuthorizationMiddleware(database *gorm.DB, authType AuthType, accessType AccessKeyType, next http.HandlerFunc) http.HandlerFunc

func LoggingMiddleware

func LoggingMiddleware(prefix string, next http.HandlerFunc) http.HandlerFunc

func NotFoundHandler

func NotFoundHandler(writer http.ResponseWriter, err error)

func Proxy

func Proxy(wr http.ResponseWriter, req *http.Request, rawUrl string) error

func RespondError

func RespondError(w http.ResponseWriter, message string)

func WriteResponse

func WriteResponse(writer http.ResponseWriter, response interface{}) error

Types

type AccessKeyType

type AccessKeyType struct {
	Type string
}

invoice key or admin key requirement

type AuthType

type AuthType struct {
	Type    string
	Decoder func(s string) ([]byte, error)
}

type BalanceResponse

type BalanceResponse struct {
	Balance int64 `json:"balance"`
}

type CreateInvoiceRequest

type CreateInvoiceRequest struct {
	Memo                string `json:"memo"`
	Amount              int64  `json:"amount"`
	DescriptionHash     string `json:"description_hash"`
	UnhashedDescription string `json:"unhashed_description"`
}

type CreateInvoiceResponse

type CreateInvoiceResponse struct {
	PaymentHash string `json:"payment_hash"`
	PayRequest  string `json:"pay_request"`
	Preimage    string `json:"preimage,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"error"`
}

type InvoiceStatusResponse

type InvoiceStatusResponse struct {
	State       string `json:"state,omitempty"`
	PaymentHash string `json:"payment_hash"`
	Preimage    int64  `json:"preimage"`
}

type InvoiceStream

type InvoiceStream struct {
	CheckingID  string `json:"checking_id"`
	Pending     bool   `json:"pending"`
	Amount      int    `json:"amount"`
	Fee         int    `json:"fee"`
	Memo        string `json:"memo"`
	Time        int    `json:"time"`
	Bolt11      string `json:"bolt11"`
	Preimage    string `json:"preimage"`
	PaymentHash string `json:"payment_hash"`
	Extra       struct {
	} `json:"extra"`
	WalletID      string      `json:"wallet_id"`
	Webhook       string      `json:"webhook"`
	WebhookStatus interface{} `json:"webhook_status"`
}

type PayInvoiceRequest

type PayInvoiceRequest struct {
	PayRequest string `json:"pay_req"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(address string) *Server

func (*Server) AppendAuthorizedRoute

func (w *Server) AppendAuthorizedRoute(path string, authType AuthType, accessType AccessKeyType, database *gorm.DB, handler func(http.ResponseWriter, *http.Request), methods ...string)

func (*Server) AppendRoute

func (w *Server) AppendRoute(path string, handler func(http.ResponseWriter, *http.Request), methods ...string)

func (*Server) ListenAndServe

func (w *Server) ListenAndServe()

func (*Server) PathPrefix

func (w *Server) PathPrefix(path string, handler http.Handler)

type Service

type Service struct {
	Bot *telegram.TipBot
}

func (Service) Balance

func (s Service) Balance(w http.ResponseWriter, r *http.Request)

func (Service) CreateInvoice

func (s Service) CreateInvoice(w http.ResponseWriter, r *http.Request)

func (Service) InvoiceStatus

func (s Service) InvoiceStatus(w http.ResponseWriter, r *http.Request)

InvoiceStatus

func (Service) InvoiceStream

func (s Service) InvoiceStream(w http.ResponseWriter, r *http.Request)

func (Service) PayInvoice

func (s Service) PayInvoice(w http.ResponseWriter, r *http.Request)

func (Service) PaymentStatus

func (s Service) PaymentStatus(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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