Files
fn-serverless/api/server/special_handler_context.go
Pedro Nasser 2c56e7975d Improve listeners and handlers (#350)
* improve listeners and handlers

* add to route handlers

* separate create/delete/update events

* removed useless interface
2016-11-29 00:00:12 +01:00

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)
}