golain

package
v0.0.0-...-692fcab Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body[B any](c *Ctx) B

Body returns body from Ctx

func Headers

func Headers[H any](c *Ctx) H

Headers returns query headers from Ctx

func InitReflector

func InitReflector(port int, addresses []string, opts *OASOptions) *openapi3.Reflector

InitReflector ...

func Params

func Params[P any](c *Ctx) P

Params return path parameters from Ctx

func Query

func Query[Q any](c *Ctx) Q

Query returns query parameters from Ctx

func WithOIDC

func WithOIDC(ref *openapi3.Reflector, url, client, secret string)

WithOIDC ...

Types

type AppRouter

type AppRouter interface {
	Use(fn func(r *AppRouter)) AppRouter
	WithDefaultMiddleware() AppRouter
	WithRoute(method, path string, fn []HandlerFunc) AppRouter
	WithTracing(url ...string) AppRouter
	WithMetrics() AppRouter
	WithFrontend(data embed.FS) AppRouter
	WithQueue(url, pw string, opts queue.Queues, fn func(q *queue.Queue)) AppRouter
	Run()
}

AppRouter ...

type AppRouterOptions

type AppRouterOptions struct {
	ID            string
	Version       string
	Host          string
	Port          int
	Banner        bool
	RequestLogger bool
}

AppRouterOptions ...

type Ctx

type Ctx struct {
	Params  map[string]string
	Query   map[string]string
	Headers map[string]string
	Body    []byte
	Context context.Context
}

Ctx ...

func NewCtx

func NewCtx() *Ctx

NewCtx ...

func (*Ctx) JSON

func (c *Ctx) JSON(data any, statusCode ...int) *Res

JSON ...

func (*Ctx) SetBody

func (c *Ctx) SetBody(b []byte) *Ctx

SetBody is a setter for Ctx.Body

func (*Ctx) SetContext

func (c *Ctx) SetContext(ctx context.Context) *Ctx

SetContext is a setter for Ctx.Context

func (*Ctx) SetHeaders

func (c *Ctx) SetHeaders(h map[string]string) *Ctx

SetHeaders is a setter for Ctx.Headers

func (*Ctx) SetParams

func (c *Ctx) SetParams(p map[string]string) *Ctx

SetParams is a setter for Ctx.Params

func (*Ctx) SetQuery

func (c *Ctx) SetQuery(q map[string]string) *Ctx

SetQuery is a setter for Ctx.Query

type EchoRouter

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

EchoRouter ...

func (*EchoRouter) Run

func (f *EchoRouter) Run()

Run ...

func (*EchoRouter) Use

func (f *EchoRouter) Use(fn func(r *AppRouter)) AppRouter

Use ...

func (*EchoRouter) WithDefaultMiddleware

func (f *EchoRouter) WithDefaultMiddleware() AppRouter

WithDefaultMiddleware ...

func (*EchoRouter) WithFrontend

func (f *EchoRouter) WithFrontend(data embed.FS) AppRouter

WithFrontend ...

func (*EchoRouter) WithMetrics

func (f *EchoRouter) WithMetrics() AppRouter

WithMetrics ...

func (*EchoRouter) WithQueue

func (f *EchoRouter) WithQueue(url, pw string, opts queue.Queues, fn func(q *queue.Queue)) AppRouter

WithQueue ...

func (*EchoRouter) WithRequestLogger

func (f *EchoRouter) WithRequestLogger() AppRouter

WithRequestLogger ...

func (*EchoRouter) WithRoute

func (f *EchoRouter) WithRoute(method, path string, fn []HandlerFunc) AppRouter

WithRoute ...

func (*EchoRouter) WithTracing

func (f *EchoRouter) WithTracing(url ...string) AppRouter

WithTracing ...

type FiberRouter

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

FiberRouter ...

func (*FiberRouter) Run

func (f *FiberRouter) Run()

Run ...

func (*FiberRouter) Use

func (f *FiberRouter) Use(fn func(r *AppRouter)) AppRouter

Use ...

func (*FiberRouter) WithDefaultMiddleware

func (f *FiberRouter) WithDefaultMiddleware() AppRouter

WithDefaultMiddleware ...

func (*FiberRouter) WithFrontend

func (f *FiberRouter) WithFrontend(data embed.FS) AppRouter

WithFrontend ...

func (*FiberRouter) WithMetrics

func (f *FiberRouter) WithMetrics() AppRouter

WithMetrics ...

func (*FiberRouter) WithQueue

func (f *FiberRouter) WithQueue(url, pw string, opts queue.Queues, fn func(q *queue.Queue)) AppRouter

WithQueue ...

func (*FiberRouter) WithRequestLogger

func (f *FiberRouter) WithRequestLogger() AppRouter

WithRequestLogger ...

func (*FiberRouter) WithRoute

func (f *FiberRouter) WithRoute(method, path string, fn []HandlerFunc) AppRouter

WithRoute ...

func (*FiberRouter) WithTracing

func (f *FiberRouter) WithTracing(url ...string) AppRouter

WithTracing ...

type Golain

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

Golain ...

func New

func New(opts ...Option) *Golain

New ...

func (*Golain) EnableMetrics

func (g *Golain) EnableMetrics() *Golain

EnableMetrics ...

func (*Golain) EnableQueue

func (g *Golain) EnableQueue(url, pw string, opts queue.Queues, fn func(q *queue.Queue)) *Golain

EnableQueue ...

func (*Golain) EnableTracing

func (g *Golain) EnableTracing(url ...string) *Golain

EnableTracing ...

func (*Golain) Register

func (g *Golain) Register(fn func(g *Golain)) *Golain

Register ...

func (*Golain) RegisterRoutes

func (g *Golain) RegisterRoutes(routes ...*Route) *Golain

RegisterRoutes ...

func (*Golain) Run

func (g *Golain) Run()

Run ...

func (*Golain) WithDefaultMiddleware

func (g *Golain) WithDefaultMiddleware() *Golain

WithDefaultMiddleware ...

type HandlerFunc

type HandlerFunc func(c *Ctx) *Res

HandlerFunc ...

type OASOptions

type OASOptions struct {
	Title       string
	Description string
	Version     string
	OASVersion  string
	AuthURL     string
	AuthClient  string
	AuthSecret  string
}

OASOptions ...

type Option

type Option func(g *Golain) error

Option represents option function

func WithAppRouter

func WithAppRouter(r AppRouter) Option

WithAppRouter ...

func WithEcho

func WithEcho(port int, opts ...AppRouterOptions) Option

WithEcho ...

func WithFiber

func WithFiber(port int, opts ...AppRouterOptions) Option

WithFiber ...

type Res

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

Res ...

type Route

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

Route ...

func Delete

func Delete[T interface{}](path string, handlers ...HandlerFunc) *Route

Delete creates a DELETE route

func Get

func Get[T any](path string, handlers ...HandlerFunc) *Route

Get creates a GET route

func Patch

func Patch[T interface{}, D interface{}](path string, handlers ...HandlerFunc) *Route

Patch creates a PATCH route

func Post

func Post[T interface{}, D interface{}](path string, handlers ...HandlerFunc) *Route

Post creates a POST route

func Put

func Put[T interface{}, D interface{}](path string, handlers ...HandlerFunc) *Route

Put creates a PUT route

type Router

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

Router holds routes

func NewRouter

func NewRouter() *Router

NewRouter is a singleton returning method for Router

func (*Router) Group

func (r *Router) Group(name string) *Router

Group groups routes under a common tag

func (*Router) Prefix

func (r *Router) Prefix(url string) *Router

Prefix adds an url prefix

func (*Router) Register

func (r *Router) Register(routes ...*Route) *Router

Register registers one or more routes

Jump to

Keyboard shortcuts

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