Documentation
¶
Index ¶
- Constants
- func InList[T comparable](value T, list []T) bool
- type Configs
- type ConnectionType
- type Endpoint
- type HttpServer
- type Method
- type Middleware
- func (m *Middleware) GetFn() func(ctx context.Context, r *Request) error
- func (m *Middleware) GetName() string
- func (m *Middleware) Run(ctx context.Context, r *Request) error
- func (m *Middleware) SetFn(fn func(ctx context.Context, r *Request) error)
- func (m *Middleware) SetName(name string)
- func (m *Middleware) ShouldActOn(method string) bool
- type NatsServer
- type Request
- func (r *Request) AssignTo(dest interface{}) error
- func (r *Request) GetBody() map[string]interface{}
- func (r *Request) GetContext() context.Context
- func (r *Request) GetFiles() map[string][]*multipart.FileHeader
- func (r *Request) GetFormFields() map[string][]string
- func (r *Request) GetHeader() map[string]interface{}
- func (r *Request) GetParams() map[string]interface{}
- func (r *Request) GetQueryParams() map[string]interface{}
- func (r *Request) GetValue(key string) interface{}
- func (r *Request) HasBody(key string) bool
- func (r *Request) HasFile(key string) bool
- func (r *Request) HasFormField(key string) bool
- func (r *Request) HasHeader(key string) bool
- func (r *Request) HasParam(key string) bool
- func (r *Request) HasQueryParam(key string) bool
- func (r *Request) HasValue(key string) bool
- func (r *Request) SetBodyValue(key string, value interface{})
- func (r *Request) SetContext(ctx context.Context)
- func (r *Request) SetFileValue(key string, value []*multipart.FileHeader)
- func (r *Request) SetFormFieldValue(key string, value []string)
- func (r *Request) SetHeaderValue(key string, value interface{})
- func (r *Request) SetParamValue(key string, value interface{})
- func (r *Request) SetQueryParamValue(key string, value interface{})
- func (r *Request) ToJsonBytes() ([]byte, error)
- type Response
- func (r *Response) GetCode() int
- func (r *Response) GetData() any
- func (r *Response) GetErrors() []string
- func (r *Response) IsSuccess() bool
- func (r *Response) SetCode(code int)
- func (r *Response) SetData(data any)
- func (r *Response) SetErrors(errors []string)
- func (r *Response) ToJsonBytes() []byte
- type Route
- type Router
- type Routes
Constants ¶
View Source
const EndpointTypeHTTP = "http"
View Source
const EndpointTypeNATS = "nats"
Variables ¶
This section is empty.
Functions ¶
func InList ¶ added in v0.0.2
func InList[T comparable](value T, list []T) bool
Types ¶
type Configs ¶
type Configs struct {
Port int `json:"port"`
Host string `json:"host"`
ApiKey string `json:"api_key"`
Type ConnectionType `json:"type"`
}
func (Configs) ConnectionTypeAllowed ¶
type ConnectionType ¶
type ConnectionType string
const ( HTTP ConnectionType = "http" NATS ConnectionType = "nats" )
type HttpServer ¶
type HttpServer struct {
Configs Configs `json:"configs" yaml:"configs"`
// contains filtered or unexported fields
}
func (*HttpServer) Start ¶
func (h *HttpServer) Start(routes Routes) error
type Middleware ¶
type Middleware struct {
Fn func(ctx context.Context, r *Request) error
Name string
ActOn []string
}
func NewMiddleware ¶
func (*Middleware) GetName ¶
func (m *Middleware) GetName() string
func (*Middleware) SetFn ¶
func (m *Middleware) SetFn(fn func(ctx context.Context, r *Request) error)
func (*Middleware) SetName ¶
func (m *Middleware) SetName(name string)
func (*Middleware) ShouldActOn ¶ added in v0.0.3
func (m *Middleware) ShouldActOn(method string) bool
type NatsServer ¶
type NatsServer struct {
Configs Configs `json:"configs" yaml:"configs"`
// contains filtered or unexported fields
}
func (*NatsServer) ConnectNats ¶
func (s *NatsServer) ConnectNats(routes Routes) error
type Request ¶
type Request struct {
Body map[string]interface{} `json:"body"`
Header map[string]interface{} `json:"header"`
QueryParams map[string]interface{} `json:"query_params,omitempty"`
Params map[string]interface{} `json:"params,omitempty"`
Files map[string][]*multipart.FileHeader `json:"files,omitempty"`
FormFields map[string][]string `json:"form_fields,omitempty"`
Context context.Context `json:"-"`
}
func (*Request) GetContext ¶
func (*Request) GetFormFields ¶
func (*Request) GetQueryParams ¶
func (*Request) HasFormField ¶
func (*Request) HasQueryParam ¶
func (*Request) SetBodyValue ¶
func (*Request) SetContext ¶
func (*Request) SetFileValue ¶
func (r *Request) SetFileValue(key string, value []*multipart.FileHeader)
func (*Request) SetFormFieldValue ¶
func (*Request) SetHeaderValue ¶
func (*Request) SetParamValue ¶
func (*Request) SetQueryParamValue ¶
func (*Request) ToJsonBytes ¶
type Response ¶
type Response struct {
Data any `json:"results,omitempty"`
Errors []string `json:"errors,omitempty"`
Code int `json:"code"`
}
func NewErrorResponse ¶
func NewResponse ¶
func (*Response) ToJsonBytes ¶
Click to show internal directories.
Click to hide internal directories.