mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* improve listeners and handlers * add to route handlers * separate create/delete/update events * removed useless interface
35 lines
734 B
Go
35 lines
734 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"context"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/iron-io/functions/api/models"
|
|
)
|
|
|
|
type SpecialHandlerContext struct {
|
|
server *Server
|
|
ginContext *gin.Context
|
|
}
|
|
|
|
func (c *SpecialHandlerContext) Context() context.Context {
|
|
ctx, _ := c.ginContext.Get("ctx")
|
|
return ctx.(context.Context)
|
|
}
|
|
|
|
func (c *SpecialHandlerContext) Request() *http.Request {
|
|
return c.ginContext.Request
|
|
}
|
|
|
|
func (c *SpecialHandlerContext) Datastore() models.Datastore {
|
|
return c.server.Datastore
|
|
}
|
|
|
|
func (c *SpecialHandlerContext) Set(key string, value interface{}) {
|
|
c.ginContext.Set(key, value)
|
|
}
|
|
func (c *SpecialHandlerContext) Get(key string) (value interface{}, exists bool) {
|
|
return c.ginContext.Get(key)
|
|
}
|