当前位置: 首页>>代码示例>>Golang>>正文


Golang bone.GetValue函数代码示例

本文整理汇总了Golang中github.com/go-zoo/bone.GetValue函数的典型用法代码示例。如果您正苦于以下问题:Golang GetValue函数的具体用法?Golang GetValue怎么用?Golang GetValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: scenarioStubsHandler

func (h *DBHandler) scenarioStubsHandler(rw http.ResponseWriter, req *http.Request) {
	// stubo ID, should be stored in database
	id := bone.GetValue(req, "id")
	u, err := strconv.ParseUint(id, 10, 64)
	if err != nil {
		http.Error(rw, "Bad stubo ID.", 400)
		return
	}
	var stubo Stubo
	// getting stubo from database
	stubo = h.getStuboDetails(u)

	// getting all scenarios
	client := &Client{&http.Client{}}
	scenarioName := bone.GetValue(req, "scenario")
	stuboURI := stubo.Protocol + "://" + stubo.Hostname + ":" + stubo.Port

	stubs, err := client.getScenarioStubs(stuboURI, scenarioName)
	if err != nil {
		http.Error(rw, "Failed to get scenario stubs from Stubo!", 400)
		return
	}

	newmap := map[string]interface{}{"metatitle": "Scenario Stubs", "Scenario": scenarioName, "Stubo": stubo, "Stubs": stubs}
	h.r.HTML(rw, http.StatusOK, "scenarioStubs", newmap)
}
开发者ID:rusenask,项目名称:overseer,代码行数:26,代码来源:handlers.go

示例2: varHandler

func varHandler(rw http.ResponseWriter, req *http.Request) {
	varr := bone.GetValue(req, "var")
	test := bone.GetValue(req, "test")
	log.Println("VAR = ", varr)
	log.Println("TEST = ", test)

	rw.Write([]byte(varr + " " + test))
}
开发者ID:JustAdam,项目名称:dbsync,代码行数:8,代码来源:example.go

示例3: PutKey

func (ss *StaticServer) PutKey(rw http.ResponseWriter, req *http.Request) {
	key := bone.GetValue(req, "key")
	value := bone.GetValue(req, "value")
	ss.setS3RootIfPresent(key, value)

	if err := ss.mkv.Upsert(key, value); err != nil {
		util.WriteError(rw, "STAT-201", err)
		return
	}
	util.WriteJSON(rw, value)
}
开发者ID:AchievementNetwork,项目名称:static,代码行数:11,代码来源:handlers.go

示例4: GetIDForHash

func (ss *StaticServer) GetIDForHash(rw http.ResponseWriter, req *http.Request) {
	name := bone.GetValue(req, "idname")
	hash := bone.GetValue(req, "hash")

	id, err := ss.mkv.GetIDFor(name, hash)

	if err != nil {
		util.WriteError(rw, "STAT-251", err)
		return
	}
	util.WriteJSON(rw, id)
}
开发者ID:AchievementNetwork,项目名称:static,代码行数:12,代码来源:handlers.go

示例5: vaultAPIAdcpSerialGetHandler

// Get the ADCP from the given serial number value.
func vaultAPIAdcpSerialGetHandler(w http.ResponseWriter, r *http.Request) {
	// Get the value of the "id" parameters.
	id := bone.GetValue(r, "id")

	switch r.Method {
	case "GET":
		{
			adcp := getAdcp(id)

			fmt.Printf("Get ADCP from serial: %s  %v", id, adcp)

			// Set data type and OK status
			w.Header().Set("Content-Type", "application/json; charset=UTF-8")
			w.WriteHeader(http.StatusOK)

			if err := json.NewEncoder(w).Encode(adcp); err != nil {
				panic(err)
			}
		}
	case "POST":
		{

		}
	default:
		{

		}

	}
}
开发者ID:ricorx7,项目名称:go-vault,代码行数:31,代码来源:vault_api.go

示例6: DeliveryHandler

func DeliveryHandler(w http.ResponseWriter, r *http.Request) {
	keyId := bone.GetValue(r, "key")
	c := appengine.NewContext(r)
	key, err := datastore.DecodeKey(keyId)
	var dbRequest MainRequest
	if err = datastore.Get(c, key, &dbRequest); err != nil {
		c.Errorf("%s", err)
	}

	var status *postmates.Status

	if dbRequest.Pm_delivery_id == "" {
		status, err = postmates.RescueDelivery(c)
		if status != nil {
			dbRequest.Pm_delivery_id = status.ID
			if _, err := datastore.Put(c, key, &dbRequest); err != nil {
				c.Errorf("%s", err)
			}
		}
	} else {
		status, err = postmates.GetStatus(c, dbRequest.Pm_delivery_id)
		if err != nil {
			c.Errorf("%s", err)
		}
	}

	// send back important info
	err = json.NewEncoder(w).Encode(&status)
	if err != nil {
		c.Errorf("%s", err)
	}
}
开发者ID:matthewdu,项目名称:powerplug,代码行数:32,代码来源:server.go

示例7: stuboDetailedHandler

func (h *DBHandler) stuboDetailedHandler(rw http.ResponseWriter, req *http.Request) {
	id := bone.GetValue(req, "id")
	u, err := strconv.ParseUint(id, 10, 64)
	if err != nil {
		http.Error(rw, "Bad stubo ID.", 400)
		return
	}
	var stubo Stubo
	// getting stubo from database
	stubo = h.getStuboDetails(u)
	stuboURI := stubo.Protocol + "://" + stubo.Hostname + ":" + stubo.Port

	// getting all scenarios
	client := &Client{&http.Client{}}
	scenarios, err := client.getScenarios(stuboURI)
	if err != nil {
		http.Error(rw, "Failed to get scenarios from Stubo!", 400)
		return
	}
	log.WithFields(log.Fields{
		"id":             id,
		"url_path":       req.URL.Path,
		"scenario_count": len(scenarios),
	}).Info("Stubo details fetched")

	newmap := map[string]interface{}{"metatitle": "Stubo Details", "Stubo": stubo, "Scenarios": scenarios}
	h.r.HTML(rw, http.StatusOK, "stuboDetails", newmap)
}
开发者ID:rusenask,项目名称:overseer,代码行数:28,代码来源:handlers.go

示例8: GetDevice

/**
 * GetDevice()
 */
func GetDevice(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")

	Db := db.MgoDb{}
	Db.Init()
	defer Db.Close()

	id := bone.GetValue(r, "device_id")

	result := models.Device{}
	err := Db.C("devices").Find(bson.M{"id": id}).One(&result)
	if err != nil {
		log.Print(err)
		w.WriteHeader(http.StatusNotFound)
		str := `{"response": "not found", "id": "` + id + `"}`
		if err != nil {
			log.Print(err)
		}
		io.WriteString(w, str)
		return
	}

	w.WriteHeader(http.StatusOK)
	res, err := json.Marshal(result)
	if err != nil {
		log.Print(err)
	}
	io.WriteString(w, string(res))
}
开发者ID:nmarcetic,项目名称:mainflux,代码行数:32,代码来源:devices.go

示例9: usernameHandler

// Handle a request tho the root reesource
func usernameHandler(w http.ResponseWriter, r *http.Request) {
	username := bone.GetValue(r, "username")

	if err := json.NewEncoder(w).Encode(username); err != nil {
		panic(err)
	}
}
开发者ID:joshproehl,项目名称:minecontrol,代码行数:8,代码来源:userHandlers.go

示例10: vaultAPICompassCalSelectGetHandler

// Set the Compass Cal Selected value.  This will invert the value that is in the database.
func vaultAPICompassCalSelectGetHandler(w http.ResponseWriter, r *http.Request) {
	// Get the value of the "id" parameters.
	id := bone.GetValue(r, "id")

	switch r.Method {
	case "GET":
		{
			compassCal := getCompassCalResultsID(id)
			compassCal.IsSelected = !compassCal.IsSelected // Invert the value

			// Pass the data back to the database
			updateCompassCal(compassCal)

			fmt.Printf("given CompassCal: %v\n", compassCal)

			// Set data type and OK status
			w.Header().Set("Content-Type", "application/json; charset=UTF-8")
			w.WriteHeader(http.StatusOK)

			if err := json.NewEncoder(w).Encode(compassCal); err != nil {
				panic(err)
			}
		}
	case "POST":
		{

		}
	default:
		{

		}

	}
}
开发者ID:ricorx7,项目名称:go-vault,代码行数:35,代码来源:vault_api.go

示例11: vaultAPIAdcpCertGetHandler

// Get the ADCP Cert info the given serial number value.
func vaultAPIAdcpCertGetHandler(w http.ResponseWriter, r *http.Request) {
	// Get the value of the "id" parameters.
	serialNum := bone.GetValue(r, "id") // Get the value of the "id" parameters in the URL.

	switch r.Method {
	case "GET":
		{
			adcp := getAdcp(serialNum)                                 // Get the ADCP data from the DB
			adcpCert := &AdcpCert{Adcp: *adcp}                         // Set the ADCP to struct
			adcpCert.CompassCal = getCompassCalCertData(serialNum)     // Get Compass Cal from the DB
			adcpCert.TankTest = getTankTestResultCertData(serialNum)   // Get Tank Test from the DB
			adcpCert.SnrTest = getSnrTestResultCertData(serialNum)     // Get SNR Test from the DB
			adcpCert.WaterTest = getWaterTestResultCertData(serialNum) // Get Water Test from the DB

			fmt.Printf("Get ADCP from serial: %s  %v", serialNum, adcpCert)

			// Set data type and OK status
			w.Header().Set("Content-Type", "application/json; charset=UTF-8")
			w.WriteHeader(http.StatusOK)

			if err := json.NewEncoder(w).Encode(adcpCert); err != nil {
				panic(err)
			}
		}
	case "POST":
		{

		}
	default:
		{

		}

	}
}
开发者ID:ricorx7,项目名称:go-vault,代码行数:36,代码来源:vault_api.go

示例12: main

func main() {
	db, err := sql.Open("postgres", "user=laptop dbname=estelle_test sslmode=disable")
	if err != nil {
		log.Fatal(err)
	}

	r := render.New(render.Options{
		Directory:  "views",
		Extensions: []string{".html"},
	})

	mux := bone.New()
	ServeResource := assets.ServeResource
	mux.HandleFunc("/img/", ServeResource)
	mux.HandleFunc("/css/", ServeResource)
	mux.HandleFunc("/js/", ServeResource)

	mux.HandleFunc("/pages", func(w http.ResponseWriter, req *http.Request) {
		rows, err := db.Query("SELECT id, title FROM pages")
		if err != nil {
			log.Fatal(err)
		}
		defer rows.Close()
		type yourtype struct {
			Id    int
			Title string
		}

		s := []yourtype{}
		for rows.Next() {
			var t yourtype
			if err := rows.Scan(&t.Id, &t.Title); err != nil {
				log.Fatal(err)
			}
			fmt.Printf("%s", t.Title)
			s = append(s, t)
		}
		r.HTML(w, http.StatusOK, "foofoo", s)
	})

	mux.HandleFunc("/bar", func(w http.ResponseWriter, req *http.Request) {
		r.HTML(w, http.StatusOK, "bar", nil)
	})

	mux.HandleFunc("/home/:id", func(w http.ResponseWriter, req *http.Request) {
		id := bone.GetValue(req, "id")
		r.HTML(w, http.StatusOK, "index", id)
	})

	mux.HandleFunc("/foo", func(w http.ResponseWriter, req *http.Request) {
		r.HTML(w, http.StatusOK, "foo", nil)
	})

	mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		r.HTML(w, http.StatusOK, "index", nil)
	})

	http.ListenAndServe(":8080", mux)
}
开发者ID:AppyCat,项目名称:go-crud-app,代码行数:59,代码来源:main.go

示例13: RemoveKey

func (ss *StaticServer) RemoveKey(rw http.ResponseWriter, req *http.Request) {
	key := bone.GetValue(req, "key")

	err := ss.mkv.Remove(key)

	if err != nil {
		util.WriteError(rw, "STAT-231", err)
	}
}
开发者ID:AchievementNetwork,项目名称:static,代码行数:9,代码来源:handlers.go

示例14: dumpHandler

func dumpHandler(w http.ResponseWriter, r *http.Request) {
	database := bone.GetValue(r, "name")
	ignore := r.FormValue("ignore")
	// ignore=cache*,voting*
	tableIgnore := make([]string, 0)
	if ignore != "" {
		tableIgnore = strings.Split(ignore, ",")
	}
	// limit=5000
	limitStr := r.FormValue("limit")
	var limit int64
	if limitStr != "" {
		var err error
		limit, err = strconv.ParseInt(limitStr, 0, 0)
		if err != nil {
			w.WriteHeader(http.StatusBadRequest)
			w.Write([]byte(`Invalid limit variable supplied`))
			log.Println(err)
			return
		}
	}

	log.Printf("Dump of %s requested from %s", database, r.RemoteAddr)

	dumpReady := make(chan DumpReady, 1)
	dumpSent := make(chan bool, 1)
	dr := &DumpRequest{
		ID:          database,
		Name:        database,
		TableIgnore: tableIgnore,
		Limit:       int(limit),
		Finished:    dumpReady,
		Sent:        dumpSent,
	}
	dumpQueue <- dr

	dur := <-dumpReady
	if dur.Error != nil {
		w.WriteHeader(http.StatusNotFound)
		w.Write([]byte(fmt.Sprint(dur.Error)))
		log.Println(dur.Error)
	} else {
		w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s-db-dump.tar.gz", database))
		w.Header().Set("Content-Type", "application/x-gzip")
		w.Header().Set("Content-Transfer-Encoding", "binary")

		http.ServeFile(w, r, dur.File)

		log.Printf("Dump of %s sent to %s", database, r.RemoteAddr)
	}

	//w.(http.Flusher).Flush()

	// Notify that the file has been sent to the client
	dumpSent <- true
}
开发者ID:JustAdam,项目名称:dbsync,代码行数:56,代码来源:server.go

示例15: GenID

func (ss *StaticServer) GenID(rw http.ResponseWriter, req *http.Request) {
	name := bone.GetValue(req, "idname")

	id, err := ss.mkv.GetNextID(name)

	if err != nil {
		util.WriteError(rw, "STAT-261", err)
	}
	util.WriteJSON(rw, id)
}
开发者ID:AchievementNetwork,项目名称:static,代码行数:10,代码来源:handlers.go


注:本文中的github.com/go-zoo/bone.GetValue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。