restresolver

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderRequestID = "X-Request-Id"

Variables

View Source
var (
	ContextKeyRequestID = RequestIDContextKey(requestID)
)

Functions

func MiddlewareCookie

func MiddlewareCookie(c *Context) error

func MiddlewareCors

func MiddlewareCors(c *Context) error

func MiddlewareRecover

func MiddlewareRecover(c *Context) error

func MiddlewareRequestID

func MiddlewareRequestID(c *Context) error

func MiddlewareRequestLog

func MiddlewareRequestLog(c *Context) error

func TransformHandlers added in v0.0.5

func TransformHandlers(
	r *app.Resource,
	handlers []Handler,
	l app.Logger,
) []fiber.Handler

Types

type Config

type Config struct {
	AppName     string
	JSONEncoder utils.JSONMarshal
	Logger      app.Logger
}

type Context

type Context struct {
	*fiber.Ctx
	// contains filtered or unexported fields
}

func CreateContext added in v0.0.5

func CreateContext(r *app.Resource, c *fiber.Ctx, logger app.Logger) *Context

func (*Context) Arg

func (c *Context) Arg(name string, defaults ...string) string

func (*Context) ArgInt

func (c *Context) ArgInt(name string, defaults ...int) int

func (*Context) Args

func (c *Context) Args() map[string]string

func (*Context) AuthToken

func (c *Context) AuthToken() string

func (*Context) Base

func (c *Context) Base() string

func (*Context) Context

func (c *Context) Context() context.Context

func (*Context) Cookie

func (c *Context) Cookie(name string, values ...*Cookie) string

func (*Context) Entity

func (c *Context) Entity() (*schema.Entity, error)

func (*Context) Files

func (c *Context) Files() ([]*app.File, error)

func (*Context) Header

func (c *Context) Header(key string, vals ...string) string

func (*Context) Hostname

func (c *Context) Hostname() string

func (*Context) ID

func (c *Context) ID() string

func (*Context) JSON

func (c *Context) JSON(v any) error

func (*Context) Logger

func (c *Context) Logger() app.Logger

func (*Context) Method

func (c *Context) Method() string

func (*Context) Next

func (c *Context) Next() error

func (*Context) OriginalURL

func (c *Context) OriginalURL() string

func (*Context) Parse

func (c *Context) Parse(v any) error

func (*Context) Path

func (c *Context) Path() string

func (*Context) Redirect

func (c *Context) Redirect(path string) error

func (*Context) Resource

func (c *Context) Resource() *app.Resource

func (*Context) Response

func (c *Context) Response() *Response

func (*Context) Result

func (c *Context) Result(results ...*app.Result) *app.Result

func (*Context) RouteName

func (c *Context) RouteName() string

func (*Context) Send

func (c *Context) Send(data []byte) error

func (*Context) Status

func (c *Context) Status(v int) *Context

func (*Context) User

func (c *Context) User() *app.User

func (*Context) Value

func (c *Context) Value(key string, value ...any) (val any)
type Cookie struct {
	Name        string    `json:"name"`
	Value       string    `json:"value"`
	Path        string    `json:"path"`
	Domain      string    `json:"domain"`
	MaxAge      int       `json:"max_age"`
	Expires     time.Time `json:"expires"`
	Secure      bool      `json:"secure"`
	HTTPOnly    bool      `json:"http_only"`
	SameSite    string    `json:"same_site"`
	SessionOnly bool      `json:"session_only"`
}

type Handler

type Handler func(c *Context) error

type RequestIDContextKey

type RequestIDContextKey string

func (RequestIDContextKey) String

func (c RequestIDContextKey) String() string

type Response

type Response struct {
	*fasthttp.Response
}

func (*Response) Header

func (r *Response) Header(key string, vals ...string) string

type RestSolver

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

func NewRestResolver

func NewRestResolver(
	resourceManager *app.ResourcesManager,
	logger app.Logger,
	staticFSs ...*app.StaticFs,
) *RestSolver

func (*RestSolver) Server added in v0.0.5

func (r *RestSolver) Server() *Server

func (*RestSolver) Shutdown added in v0.0.5

func (r *RestSolver) Shutdown() error

func (*RestSolver) Start

func (r *RestSolver) Start(address string) error

type Router

type Router struct {
	*fiber.App
	// contains filtered or unexported fields
}

func (*Router) Delete

func (g *Router) Delete(path string, handler Handler, resources ...*app.Resource)

func (*Router) Get

func (g *Router) Get(path string, handler Handler, resources ...*app.Resource)

func (*Router) Group

func (g *Router) Group(prefix string, r *app.Resource, handlers ...Handler) *Router

func (*Router) Head

func (g *Router) Head(path string, handler Handler, resources ...*app.Resource)

func (*Router) Options

func (g *Router) Options(path string, handler Handler, resources ...*app.Resource)

func (*Router) Patch

func (g *Router) Patch(path string, handler Handler, resources ...*app.Resource)

func (*Router) Post

func (g *Router) Post(path string, handler Handler, resources ...*app.Resource)

func (*Router) Put

func (g *Router) Put(path string, handler Handler, resources ...*app.Resource)

func (*Router) Use

func (g *Router) Use(handlers ...Handler)

type Server

type Server struct {
	*fiber.App
	// contains filtered or unexported fields
}

func New

func New(config Config) *Server

func (*Server) Delete

func (s *Server) Delete(path string, handler Handler, resources ...*app.Resource)

func (*Server) Get

func (s *Server) Get(path string, handler Handler, resources ...*app.Resource)

func (*Server) Group

func (s *Server) Group(prefix string, r *app.Resource, handlers ...Handler) *Router

func (*Server) Listen

func (s *Server) Listen(address string) error

func (*Server) Options

func (s *Server) Options(path string, handler Handler, resources ...*app.Resource)

func (*Server) Patch

func (s *Server) Patch(path string, handler Handler, resources ...*app.Resource)

func (*Server) Post

func (s *Server) Post(path string, handler Handler, resources ...*app.Resource)

func (*Server) Put

func (s *Server) Put(path string, handler Handler, resources ...*app.Resource)

func (*Server) Static

func (s *Server) Static(prefix, root string, configs ...StaticConfig)

func (*Server) Test

func (s *Server) Test(req *http.Request, msTimeout ...int) (resp *http.Response, err error)

func (*Server) Use

func (s *Server) Use(handlers ...Handler)

type StaticConfig

type StaticConfig struct {
	Compress      bool          `json:"compress"`
	ByteRange     bool          `json:"byte_range"`
	Browse        bool          `json:"browse"`
	Download      bool          `json:"download"`
	Index         string        `json:"index"`
	CacheDuration time.Duration `json:"cache_duration"` // Default value 10 * time.Second.
	MaxAge        int           `json:"max_age"`        // Default value 0
}

Jump to

Keyboard shortcuts

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