dongmuyuan3046 2015-05-21 16:50
浏览 19
已采纳

Referer-parser Golang:生产设置而不是使用占位符值?

referer-parser read placeholder value in the example, while the production setting is not documented.

I need referer-parser to read real referer value instead of placeholder value.

Below is my code (the referer_url read placeholder value):

package main

import (
    "github.com/labstack/echo"
    "github.com/snowplow/referer-parser/go"
    "net/http"
)

func main() {
    e := echo.New()

    referer_url := "http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari"
    r := refererparser.Parse(referer_url)

    e.Get("/users", func(c *echo.Context) *echo.HTTPError {
        return c.String(http.StatusOK, "The search term is: "+r.SearchTerm)
    })

    e.Run(":4444")
}
  • 写回答

1条回答 默认 最新

  • doubi8383 2015-05-21 19:02
    关注

    Read the value you want from the http headers inside your handler:

    e.Get("/users", func(c *echo.Context) *echo.HTTPError {
        refererURL := c.Request.Header.Get("Referer")
        r := refererparser.Parse(refererURL)
        return c.String(http.StatusOK, "The search term is: "+r.SearchTerm)
    })
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想做个WPS的自动化代码,不知道能做的起不。
  • ¥15 斯坦福自动漂移非线性模型反解
  • ¥15 学习Python如何找兼职
  • ¥15 python结合Matlab仿真忆阻器
  • ¥35 有人会注册whatsaop协议号吗?
  • ¥15 lead dbs 无法导入影像数据
  • ¥15 多目标MPA算法优化编程实现
  • ¥15 反激PWM控制芯片调研
  • ¥15 Python for loop减少运行时间
  • ¥15 fluent模拟物质浓度udf