Documentation
¶
Overview ¶
framework/fiber/adapter.go
framework/fiber/context.go
framework/fiber/middleware.go
framework/fiber/server.go
Index ¶
- Constants
- func Adapter(handler simplehttp.MedaHandlerFunc) fiber.Handler
- func MiddlewareAdapter(middleware simplehttp.MedaMiddlewareFunc) fiber.Handler
- func MiddlewareBasicAuth(username, password string) simplehttp.MedaMiddleware
- func MiddlewareCORS(config *simplehttp.CORSConfig) simplehttp.MedaMiddleware
- func MiddlewareCSRF() simplehttp.MedaMiddleware
- func MiddlewareCache(config simplehttp.CacheConfig) simplehttp.MedaMiddleware
- func MiddlewareCompress(config simplehttp.CompressionConfig) simplehttp.MedaMiddleware
- func MiddlewareETag() simplehttp.MedaMiddleware
- func MiddlewareLogger(log simplehttp.Logger) simplehttp.MedaMiddleware
- func MiddlewareMonitor() simplehttp.MedaMiddleware
- func MiddlewareRateLimiter(config simplehttp.RateLimitConfig) simplehttp.MedaMiddleware
- func MiddlewareRecover() simplehttp.MedaMiddleware
- func MiddlewareRequestID() simplehttp.MedaMiddleware
- func MiddlewareSecurity(config simplehttp.SecurityConfig) simplehttp.MedaMiddleware
- type FiberContext
- func (c *FiberContext) Bind(v interface{}) error
- func (c *FiberContext) BindForm(v interface{}) error
- func (c *FiberContext) BindJSON(v interface{}) error
- func (c *FiberContext) Context() context.Context
- func (c *FiberContext) Get(key string) interface{}
- func (c *FiberContext) GetBody() []byte
- func (c *FiberContext) GetFile(fieldName string) (*multipart.FileHeader, error)
- func (c *FiberContext) GetHeader(key string) string
- func (c *FiberContext) GetHeaders() *simplehttp.RequestHeader
- func (c *FiberContext) GetMethod() string
- func (c *FiberContext) GetPath() string
- func (c *FiberContext) GetQueryParam(key string) string
- func (c *FiberContext) GetQueryParams() map[string][]string
- func (c *FiberContext) JSON(code int, data interface{}) error
- func (c *FiberContext) Request() *http.Request
- func (c *FiberContext) Response() http.ResponseWriter
- func (c *FiberContext) SaveFile(file *multipart.FileHeader, dst string) error
- func (c *FiberContext) SendFile(filepath string, attachment bool) error
- func (c *FiberContext) Set(key string, value interface{})
- func (c *FiberContext) SetContext(ctx context.Context)
- func (c *FiberContext) SetHeader(key, value string)
- func (c *FiberContext) SetRequestHeader(key, value string)
- func (c *FiberContext) SetResponseHeader(key, value string)
- func (c *FiberContext) Stream(code int, contentType string, reader io.Reader) error
- func (c *FiberContext) String(code int, data string) error
- func (c *FiberContext) Upgrade() (simplehttp.MedaWebsocket, error)
- type FiberWebSocket
- func (ws *FiberWebSocket) Close() error
- func (ws *FiberWebSocket) ReadJSON(v interface{}) error
- func (ws *FiberWebSocket) ReadMessage() (messageType int, p []byte, err error)
- func (ws *FiberWebSocket) WriteJSON(v interface{}) error
- func (ws *FiberWebSocket) WriteMessage(messageType int, data []byte) error
- type RouterGroup
- func (g *RouterGroup) DELETE(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) GET(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) Group(prefix string) simplehttp.MedaRouter
- func (g *RouterGroup) HEAD(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) OPTIONS(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) PATCH(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) POST(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) PUT(path string, handler simplehttp.MedaHandlerFunc)
- func (g *RouterGroup) Static(prefix, root string)
- func (g *RouterGroup) StaticFile(path, filepath string)
- func (g *RouterGroup) Use(middleware ...simplehttp.MedaMiddleware)
- func (g *RouterGroup) WebSocket(path string, handler func(simplehttp.MedaWebsocket) error)
- type Server
- func (s *Server) DELETE(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) GET(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) Group(prefix string) simplehttp.MedaRouter
- func (s *Server) HEAD(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) OPTIONS(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) PATCH(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) POST(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) PUT(path string, handler simplehttp.MedaHandlerFunc)
- func (s *Server) PrintMiddleware(verbose bool)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start(address string) error
- func (s *Server) Static(prefix, root string)
- func (s *Server) StaticFile(path, filepath string)
- func (s *Server) Use(middleware ...simplehttp.MedaMiddleware)
- func (s *Server) WebSocket(path string, handler func(simplehttp.MedaWebsocket) error)
Constants ¶
const (
HEADER_PARSED_KEY = "simplehttp.header"
)
Variables ¶
This section is empty.
Functions ¶
func Adapter ¶
func Adapter(handler simplehttp.MedaHandlerFunc) fiber.Handler
Adapter converts MedaHandlerFunc to fiber.Handler
func MiddlewareAdapter ¶
func MiddlewareAdapter(middleware simplehttp.MedaMiddlewareFunc) fiber.Handler
MiddlewareAdapter converts MedaMiddleware to fiber middleware
func MiddlewareBasicAuth ¶
func MiddlewareBasicAuth(username, password string) simplehttp.MedaMiddleware
MiddlewareBasicAuth returns Fiber's basic auth middleware
func MiddlewareCORS ¶
func MiddlewareCORS(config *simplehttp.CORSConfig) simplehttp.MedaMiddleware
Example of another middleware following the same pattern
func MiddlewareCSRF ¶
func MiddlewareCSRF() simplehttp.MedaMiddleware
MiddlewareCSRF returns Fiber's CSRF middleware
func MiddlewareCache ¶
func MiddlewareCache(config simplehttp.CacheConfig) simplehttp.MedaMiddleware
MiddlewareCache returns Fiber's cache middleware
func MiddlewareCompress ¶
func MiddlewareCompress(config simplehttp.CompressionConfig) simplehttp.MedaMiddleware
MiddlewareCompress returns Fiber's compression middleware
func MiddlewareETag ¶
func MiddlewareETag() simplehttp.MedaMiddleware
MiddlewareETag returns Fiber's ETag middleware
func MiddlewareLogger ¶
func MiddlewareLogger(log simplehttp.Logger) simplehttp.MedaMiddleware
MiddlewareLogger returns Fiber's logger middleware
func MiddlewareMonitor ¶
func MiddlewareMonitor() simplehttp.MedaMiddleware
MiddlewareMonitor returns Fiber's monitor middleware
func MiddlewareRateLimiter ¶
func MiddlewareRateLimiter(config simplehttp.RateLimitConfig) simplehttp.MedaMiddleware
MiddlewareRateLimiter returns Fiber's rate limiter middleware
func MiddlewareRecover ¶
func MiddlewareRecover() simplehttp.MedaMiddleware
MiddlewareRecover returns Fiber's recover middleware
func MiddlewareRequestID ¶
func MiddlewareRequestID() simplehttp.MedaMiddleware
RequestID middleware as an example., TODO: Check and test this, last time it wasn't working!
func MiddlewareSecurity ¶
func MiddlewareSecurity(config simplehttp.SecurityConfig) simplehttp.MedaMiddleware
MiddlewareSecurity returns Fiber's security middleware (Helmet)
Types ¶
type FiberContext ¶
type FiberContext struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(c *fiber.Ctx) *FiberContext
func (*FiberContext) Bind ¶
func (c *FiberContext) Bind(v interface{}) error
func (*FiberContext) BindForm ¶
func (c *FiberContext) BindForm(v interface{}) error
func (*FiberContext) BindJSON ¶
func (c *FiberContext) BindJSON(v interface{}) error
func (*FiberContext) Get ¶
func (c *FiberContext) Get(key string) interface{}
func (*FiberContext) GetBody ¶
func (c *FiberContext) GetBody() []byte
func (*FiberContext) GetFile ¶
func (c *FiberContext) GetFile(fieldName string) (*multipart.FileHeader, error)
File handling
func (*FiberContext) GetHeader ¶
func (c *FiberContext) GetHeader(key string) string
func (*FiberContext) GetHeaders ¶
func (c *FiberContext) GetHeaders() *simplehttp.RequestHeader
func (*FiberContext) GetMethod ¶
func (c *FiberContext) GetMethod() string
func (*FiberContext) GetQueryParam ¶
func (c *FiberContext) GetQueryParam(key string) string
Query parameter handling
func (*FiberContext) GetQueryParams ¶
func (c *FiberContext) GetQueryParams() map[string][]string
func (*FiberContext) JSON ¶
func (c *FiberContext) JSON(code int, data interface{}) error
Response methods
func (*FiberContext) Request ¶
func (c *FiberContext) Request() *http.Request
Standard http.Request and http.ResponseWriter implementation
func (*FiberContext) Response ¶
func (c *FiberContext) Response() http.ResponseWriter
func (*FiberContext) SaveFile ¶
func (c *FiberContext) SaveFile(file *multipart.FileHeader, dst string) error
func (*FiberContext) SendFile ¶
func (c *FiberContext) SendFile(filepath string, attachment bool) error
func (*FiberContext) Set ¶
func (c *FiberContext) Set(key string, value interface{})
func (*FiberContext) SetContext ¶
func (c *FiberContext) SetContext(ctx context.Context)
func (*FiberContext) SetHeader ¶
func (c *FiberContext) SetHeader(key, value string)
func (*FiberContext) SetRequestHeader ¶
func (c *FiberContext) SetRequestHeader(key, value string)
Header manipulation methods
func (*FiberContext) SetResponseHeader ¶
func (c *FiberContext) SetResponseHeader(key, value string)
func (*FiberContext) Upgrade ¶
func (c *FiberContext) Upgrade() (simplehttp.MedaWebsocket, error)
WebSocket handling
type FiberWebSocket ¶
type FiberWebSocket struct {
// contains filtered or unexported fields
}
WebSocket implementation
func NewFiberWebSocket ¶
func NewFiberWebSocket(c *websocket.Conn) *FiberWebSocket
func (*FiberWebSocket) Close ¶
func (ws *FiberWebSocket) Close() error
func (*FiberWebSocket) ReadJSON ¶
func (ws *FiberWebSocket) ReadJSON(v interface{}) error
func (*FiberWebSocket) ReadMessage ¶
func (ws *FiberWebSocket) ReadMessage() (messageType int, p []byte, err error)
func (*FiberWebSocket) WriteJSON ¶
func (ws *FiberWebSocket) WriteJSON(v interface{}) error
func (*FiberWebSocket) WriteMessage ¶
func (ws *FiberWebSocket) WriteMessage(messageType int, data []byte) error
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
RouterGroup implements group routing
func (*RouterGroup) DELETE ¶
func (g *RouterGroup) DELETE(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) GET ¶
func (g *RouterGroup) GET(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) Group ¶
func (g *RouterGroup) Group(prefix string) simplehttp.MedaRouter
func (*RouterGroup) HEAD ¶
func (g *RouterGroup) HEAD(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) OPTIONS ¶
func (g *RouterGroup) OPTIONS(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) PATCH ¶
func (g *RouterGroup) PATCH(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) POST ¶
func (g *RouterGroup) POST(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) PUT ¶
func (g *RouterGroup) PUT(path string, handler simplehttp.MedaHandlerFunc)
func (*RouterGroup) Static ¶
func (g *RouterGroup) Static(prefix, root string)
func (*RouterGroup) StaticFile ¶
func (g *RouterGroup) StaticFile(path, filepath string)
func (*RouterGroup) Use ¶
func (g *RouterGroup) Use(middleware ...simplehttp.MedaMiddleware)
func (*RouterGroup) WebSocket ¶
func (g *RouterGroup) WebSocket(path string, handler func(simplehttp.MedaWebsocket) error)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config *simplehttp.Config) *Server
func (*Server) DELETE ¶
func (s *Server) DELETE(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) GET ¶
func (s *Server) GET(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) Group ¶
func (s *Server) Group(prefix string) simplehttp.MedaRouter
func (*Server) HEAD ¶
func (s *Server) HEAD(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) OPTIONS ¶
func (s *Server) OPTIONS(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) PATCH ¶
func (s *Server) PATCH(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) POST ¶
func (s *Server) POST(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) PUT ¶
func (s *Server) PUT(path string, handler simplehttp.MedaHandlerFunc)
func (*Server) PrintMiddleware ¶
func (*Server) Start ¶
Usually this is framework.Listen() function TODO: use config.Debug to print out or if not silence / minimal
func (*Server) StaticFile ¶
func (*Server) Use ¶
func (s *Server) Use(middleware ...simplehttp.MedaMiddleware)
func (*Server) WebSocket ¶
func (s *Server) WebSocket(path string, handler func(simplehttp.MedaWebsocket) error)