server

package
v0.0.0-...-cb7f019 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrResponse{StatusCode: 404, Message: "Resource not found."}

ErrNotFound is a pre-built not-found error

Functions

func ErrInternalServer

func ErrInternalServer(err error) render.Renderer

ErrInternalServer returns a generic server error to the user

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

ErrInvalidRequest is used to indicate an error on user input (with wrapped error)

func ErrInvalidRequestWithMessage

func ErrInvalidRequestWithMessage(err error) render.Renderer

ErrInvalidRequestWithMessage will log an error (as a debug log) and return an invalid request error to the user with a message.

func ErrRender

func ErrRender(err error) render.Renderer

ErrRender is used to indicate that there was an error rendering the response

func ErrRequestFailed

func ErrRequestFailed(err error) render.Renderer

ErrRequestFailed is used to indicate that user input was valid, but incorrect, hence an error

func ErrRequestUnauthorized

func ErrRequestUnauthorized(err error) render.Renderer

ErrRequestUnauthorized is used to indicate that user input was valid, but incorrect, hence an error

Types

type ApplePaySessionResponse

type ApplePaySessionResponse struct {
	EpochTimestamp            int64  `json:"epochTimestamp"`
	ExpiresAt                 int64  `json:"expiresAt"`
	MerchantSessionIdentifier string `json:"merchantSessionIdentifier"`
	Nonce                     string `json:"nonce"`
	MerchantIdentifier        string `json:"merchantIdentifier"`
	DomainName                string `json:"domainName"`
	DisplayName               string `json:"displayName"`
	Signature                 string `json:"signature"`
}

ApplePayResponse - ...

type ErrResponse

type ErrResponse struct {
	Err        error `json:"-"` // low-level runtime error
	StatusCode int   `json:"-"` // http response status code

	Message   string `json:"message"`         // user-level status message
	ErrorCode int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse is a generic struct for returning a standard error document

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

Render is the Renderer for ErrResponse struct

type Server

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

Server is the API web server

func New

func New(store buyte.Store) (*Server, error)

New will setup the API listener

func (*Server) CreateCharge

func (s *Server) CreateCharge() http.HandlerFunc

func (*Server) ErrInternalServer

func (s *Server) ErrInternalServer(err error) render.Renderer

(*Server) ErrInternalServer will log an error and return a generic server error to the user

func (*Server) ErrInvalidRequest

func (s *Server) ErrInvalidRequest(err error) render.Renderer

(*Server) ErrInvalidRequest will log an error (as a debug log) and return an invalid request error to the user

func (*Server) ErrInvalidRequestWithMessage

func (s *Server) ErrInvalidRequestWithMessage(err error) render.Renderer

(*Server) ErrInvalidRequestWithMessage will log an error (as a debug log) and return an invalid request error to the user with a message.

func (*Server) ErrRender

func (s *Server) ErrRender(err error) render.Renderer

(*Server) ErrRender will log an error (as a debug log) and return an render error to the user

func (*Server) ErrRequestFailed

func (s *Server) ErrRequestFailed(err error) render.Renderer

(*Server) ErrRequestFailed will log an error (as a debug log) and return an request failed error to the user

func (*Server) ErrRequestUnauthorized

func (s *Server) ErrRequestUnauthorized(err error) render.Renderer

(*Server) ErrRequestUnauthorized will log an error (as a debug log) and return an request failed error to the user

func (*Server) GetApplePaySession

func (s *Server) GetApplePaySession() http.HandlerFunc

func (*Server) GetCharge

func (s *Server) GetCharge() http.HandlerFunc

func (*Server) GetFullCheckout

func (s *Server) GetFullCheckout() http.HandlerFunc

func (*Server) GetPaymentToken

func (s *Server) GetPaymentToken() http.HandlerFunc

func (*Server) InitialiseServer

func (s *Server) InitialiseServer() http.Handler

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe will listen for requests

func (*Server) ProcessApplePayResponse

func (s *Server) ProcessApplePayResponse() http.HandlerFunc

func (*Server) ProcessGooglePayResponse

func (s *Server) ProcessGooglePayResponse() http.HandlerFunc

func (*Server) SetupDevRoutes

func (s *Server) SetupDevRoutes()

Routes specifically for development

func (*Server) SetupRoutes

func (s *Server) SetupRoutes()

SetupRoutes configures all the routes for this service

Jump to

Keyboard shortcuts

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