123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package httpserver
- import (
- "net/http"
- "github.com/gin-gonic/gin"
- )
- type Controller struct {
- Config *HttpServerConfig
- }
- /*
- Returns a new Controller struct to register routes to the gin router
- :param cfg: A pointer to an HttpServerConfig struct
- */
- func NewController(cfg *HttpServerConfig) *Controller {
- return &Controller{Config: cfg}
- }
- /*
- This handler will be responsible for proxying out the GET requests that the server recieves
- */
- func (c *Controller) Get(ctx *gin.Context) {
- }
- /*
- This handler will be responsible for proxying any POST requests
- */
- func (c *Controller) Post(ctx *gin.Context) {
- req, err := http.NewRequest()
- if err != nil {
- ctx.JSON(500, map[string]string{
- "Error": "Error creating the request.",
- "Msg:": err.Error(),
- })
- return
- }
- req.Header.Add("user-agent", c.Config.UserAgent)
- req.Header.Add("Referer", c.Config.AllowedDomain)
- req.Header.Add()
- }
|