Golang Context.GetQuery Examples

Golang Context.GetQuery - 11 examples found. These are the top rated real world Golang examples of github.com/gin-gonic/gin.Context.GetQuery extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
func readPodLog(c *gin.Context) {
	namespace := c.Param("ns")
	podname := c.Param("po")
	_, previous := c.GetQuery("previous")

	readLog(c, namespace, podname, "", previous)
}
Example #2
0
func editReplicationController(c *gin.Context) {
	namespace := c.Param("ns")
	rcname := c.Param("rc")
	_, delete := c.GetQuery("delete")

	rc, err := kubeclient.Get().ReplicationControllers(namespace).Get(rcname)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	b, err := json.Marshal(rc)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	var out bytes.Buffer
	err = json.Indent(&out, b, "", "  ")
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	c.HTML(http.StatusOK, "replicationControllerEdit", gin.H{
		"title":     rcname,
		"namespace": namespace,
		"objname":   rcname,
		"json":      out.String(),
		"delete":    strconv.FormatBool(delete),
	})
}
Example #3
0
func editNode(c *gin.Context) {
	nodename := c.Param("no")
	_, delete := c.GetQuery("delete")

	node, err := kubeclient.Get().Nodes().Get(nodename)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	b, err := json.Marshal(node)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	var out bytes.Buffer
	err = json.Indent(&out, b, "", "  ")
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	c.HTML(http.StatusOK, "nodeEdit", gin.H{
		"title":   nodename,
		"objname": nodename,
		"json":    out.String(),
		"delete":  strconv.FormatBool(delete),
	})
}
Example #4
0
func editEndpoints(c *gin.Context) {
	namespace := c.Param("ns")
	epname := c.Param("ep")
	_, delete := c.GetQuery("delete")

	ep, err := kubeclient.Get().Endpoints(namespace).Get(epname)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	b, err := json.Marshal(ep)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	var out bytes.Buffer
	err = json.Indent(&out, b, "", "  ")
	if err != nil {
		c.HTML(http.StatusInternalServerError, "error", gin.H{"error": err.Error()})
		return
	}

	c.HTML(http.StatusOK, "endpointsEdit", gin.H{
		"title":     epname,
		"namespace": namespace,
		"objname":   epname,
		"json":      out.String(),
		"delete":    strconv.FormatBool(delete),
	})
}
Example #5
0
func apiGetSiteInfo(g *gin.Context) {
	url, ok := g.GetQuery("url")
	if !ok {
		g.String(500, "missing parameter url")
		return
	}
	_, inclBody := g.GetQuery("body")

	cw := crawlbase.NewCrawler()
	cw.Header.Add("User-Agent", userAgentHeader)
	tags, _ := crawlbase.LoadTagsFromFile("tags.json")
	cw.Validator.AddValidTags(tags)

	page, err := cw.GetPage(url, "GET")

	if err != nil {
		g.String(500, err.Error())
	}

	// first check

	if !inclBody {
		page.RespInfo.Body = ""
	}

	g.JSON(200, page)
}
Example #6
0
func apiAddTag(g *gin.Context) {
	if g.Request.Method != "POST" {
		g.String(404, "not a get")
		return
	}

	tName, _ := g.GetQuery("TagName")
	aName, _ := g.GetQuery("AttributeName")

	if tName == "" {
		g.String(200, "TagName is empty")
		return
	}

	tags, _ := crawlbase.LoadTagsFromFile("tags.json")
	tag, ok := findTag(tags, tName)
	if !ok {
		tag = &htmlcheck.ValidTag{tName, []string{}, "", false}
		tags = append(tags, tag)
	}

	ok = findString(tag.Attrs, aName)
	if !ok {
		tag.Attrs = append(tag.Attrs, aName)
	}

	//t, _ := findTag(tags, tName)
	crawlbase.WriteTagsToFile(tags, "tags.json")

	g.String(200, "ok")
}