app

package
v0.0.0-...-07f0968 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB int64 = 1000
	MB int64 = 1000000
	GB int64 = 1000000000

	ApiPathPrefix        = "/api"
	ApiPathPrefixSegment = ApiPathPrefix + "/"
)

Variables

This section is empty.

Functions

func BadReqIf

func BadReqIf(condition bool, format string, args ...interface{})

func Call

func Call(c *Client, path string, args interface{}, res interface{}) error

func ExampleID

func ExampleID() ID

func ExampleTime

func ExampleTime() time.Time

func MustCall

func MustCall(c *Client, path string, args interface{}, res interface{})

func Redirect

func Redirect(status int, url string)

func ReturnIf

func ReturnIf(condition bool, status int, format string, args ...interface{})

func Run

func Run(configs ...func(*Config))

Types

type ActionStats

type ActionStats struct {
	Milli  int64  `json:"ms"`
	Type   string `json:"type"`
	Name   string `json:"name"`
	Action string `json:"action"`
}

type Client

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

func NewClient

func NewClient(baseHref string, optClient ...httpClient) *Client

func (*Client) Cookies

func (c *Client) Cookies() map[string]string

type Config

type Config struct {
	Log                     log.Log
	Version                 string
	StaticDir               string
	ProvideApiDocs          bool
	ContentSecurityPolicies []string
	// id
	IDGenPoolSize int
	// mdo
	MDoMax          int
	MDoMaxBodyBytes int64
	// tlbx
	TlbxSetup   TlbxMwares
	TlbxCleanup TlbxMwares
	// app
	Name        string
	Description string
	Endpoints   []*Endpoint
	Serve       func(http.HandlerFunc)
}

type Docs

type Docs struct{}

func (*Docs) Do

func (a *Docs) Do(c *Client) (*json.Json, error)

func (*Docs) MustDo

func (a *Docs) MustDo(c *Client) *json.Json

func (*Docs) Path

func (_ *Docs) Path() string

type DownStream

type DownStream struct {
	ID         ID
	IsDownload bool
	// contains filtered or unexported fields
}

func (*DownStream) FromResp

func (s *DownStream) FromResp(r *http.Response) error

func (*DownStream) MarshalJSON

func (_ *DownStream) MarshalJSON() ([]byte, error)

func (*DownStream) MustFromResp

func (s *DownStream) MustFromResp(r *http.Response)

type Endpoint

type Endpoint struct {
	Description        string
	Path               string
	Timeout            int64
	SkipXClientCheck   bool
	MaxBodyBytes       int64
	IsPrivate          bool
	GetDefaultArgs     func() interface{}
	GetExampleArgs     func() interface{}
	GetExampleResponse func() interface{}
	Handler            func(tlbx Tlbx, args interface{}) interface{}
}

func JoinEps

func JoinEps(epss ...[]*Endpoint) []*Endpoint

type ErrMsg

type ErrMsg struct {
	Status int    `json:"status"`
	Msg    string `json:"message"`
}

func (*ErrMsg) Error

func (e *ErrMsg) Error() string

type MDo

type MDo map[string]*MDoReq

func (*MDo) Do

func (a *MDo) Do(c *Client) (map[string]*MDoResp, error)

func (*MDo) MustDo

func (a *MDo) MustDo(c *Client) map[string]*MDoResp

func (*MDo) Path

func (_ *MDo) Path() string

type MDoReq

type MDoReq struct {
	Header bool       `json:"header,omitempty"`
	Path   string     `json:"path,omitempty"`
	Args   *json.Json `json:"args,omitempty"`
}

type MDoResp

type MDoResp struct {
	Status int         `json:"status"`
	Header http.Header `json:"header,omitempty"`
	Body   *json.Json  `json:"body"`
}

type Ping

type Ping struct{}

func (*Ping) Do

func (a *Ping) Do(c *Client) (string, error)

func (*Ping) MustDo

func (a *Ping) MustDo(c *Client) string

func (*Ping) Path

func (_ *Ping) Path() string

type SelfValidator

type SelfValidator interface {
	MustBeValid(tlbx Tlbx)
}

type Tlbx

type Tlbx interface {
	Req() *http.Request
	Resp() http.ResponseWriter
	Start() time.Time
	StartMilli() int64
	Ctx() context.Context
	NewID() ID
	Log() log.Log
	LogActionStats(*ActionStats)
	// add any extra arbitrary stuff with these
	Get(key interface{}) interface{}
	Set(key, value interface{})
}

type TlbxMware

type TlbxMware func(Tlbx)

type TlbxMwares

type TlbxMwares []func(Tlbx)

type UpStream

type UpStream struct {
	Args interface{}
	// contains filtered or unexported fields
}

func (*UpStream) MarshalJSON

func (_ *UpStream) MarshalJSON() ([]byte, error)

func (*UpStream) MustToReq

func (s *UpStream) MustToReq(method, url string) *http.Request

func (*UpStream) ToReq

func (s *UpStream) ToReq(method, url string) (*http.Request, error)

Directories

Path Synopsis
fcm
sql
me

Jump to

Keyboard shortcuts

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