當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.NoContent方法代碼示例

本文整理匯總了Golang中github.com/labstack/echo.Context.NoContent方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.NoContent方法的具體用法?Golang Context.NoContent怎麽用?Golang Context.NoContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/labstack/echo.Context的用法示例。


在下文中一共展示了Context.NoContent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: putPlace

// putPlace изменяет определение уже существующего места.
func putPlace(c *echo.Context) error {
	groupID := c.Get("GroupID").(string)
	placeID := c.Query("place-id")
	if !bson.IsObjectIdHex(placeID) {
		return echo.NewHTTPError(http.StatusNotFound)
	}
	var place places.Place // описание места
	err := c.Bind(&place)  // разбираем описание места из запроса
	if err != nil {
		return echo.NewHTTPError(http.StatusBadRequest, err.Error())
	}
	if place.Circle == nil && place.Polygon == nil {
		return echo.NewHTTPError(http.StatusBadRequest)
	}
	place.ID = bson.ObjectIdHex(placeID)
	place.GroupID = groupID
	_, err = placesDB.Save(place)
	if err == mgo.ErrNotFound {
		return echo.NewHTTPError(http.StatusNotFound)
	}
	if err != nil {
		llog.Error("placesDB error: %v", err)
		return err
	}
	return c.NoContent(http.StatusOK)
}
開發者ID:jtprog,項目名稱:geotrack,代碼行數:27,代碼來源:places.go

示例2: deleteService

func (as ApiService) deleteService(c echo.Context) error {
	if err := as.balancer.DeleteService(c.Param("service_name")); err != nil {
		return err
	}

	return c.NoContent(http.StatusNoContent)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:7,代碼來源:handlers.go

示例3: SetupApp

// SetupApp allows the creation of a admin account if no accounts exist.
func SetupApp(c echo.Context) error {
	db := ToDB(c)
	accts, err := db.GetAccountList()
	if len(accts) > 0 || err != nil {
		return ErrForbidden.Log(err, fmt.Sprintf("total accounts: %s", len(accts)))
	}

	p := &Setup{}
	if err := c.Bind(p); err != nil {
		return ErrBind.Log(err)
	}

	p.IsAdmin = true
	if err := db.InsertPerson(&p.Person); err != nil {
		return ErrSaving.Log(err)
	}

	u, _ := model.NewAccountFor(p.PersonID, p.Email)
	if err := u.SetPassword(p.Password); err != nil {
		return ErrPasswordSimple.Log(err)
	}

	u.SetActive()

	if err := db.InsertAccount(u); err != nil {
		return ErrSaving.Log(err)
	}

	return c.NoContent(http.StatusCreated)
}
開發者ID:gogrademe,項目名稱:api,代碼行數:31,代碼來源:setup.go

示例4: putHandler

func putHandler(c echo.Context) error {
	var val map[string]interface{}

	if err := c.Bind(&val); err != nil {
		return err
	}

	cfg := c.Get("config").(*Config)

	key := c.Param("key")
	obj, err := Put(cfg, key, val)

	if err != nil {
		// Failed validation.
		if errs, ok := err.(ResultErrors); ok {
			return c.JSON(StatusUnprocessableEntity, errs)
		}

		return err
	}

	// No change.
	if obj == nil {
		return c.NoContent(http.StatusNoContent)
	}

	return c.JSON(http.StatusOK, obj)
}
開發者ID:chop-dbhi,項目名稱:scds,代碼行數:28,代碼來源:http.go

示例5: warmupHandler

func warmupHandler(c *echo.Context) error {
	if appengine.IsDevAppServer() {
		photographers := []Photographer{
			{1, "Mr Canon"},
			{2, "Miss Nikon"},
			{3, "Mrs Pentax"},
			{4, "Ms Sony"},
		}

		// create some dummy data
		for m := 1; m <= 12; m++ {
			for d := 1; d < 28; d++ {
				taken := time.Date(2015, time.Month(m), d, 12, 0, 0, 0, time.UTC)
				id := rand.Int31n(4)
				photographer := photographers[id]
				p := Photo{
					Photographer: photographer,
					Uploaded:     time.Now().UTC(),
					Width:        8000,
					Height:       6000,
					Taken:        taken,
				}
				k := datastore.NewIncompleteKey(c, "photo", nil)
				nds.Put(c, k, &p)
			}
		}
	}
	return c.NoContent(http.StatusOK)
}
開發者ID:komasoftware,項目名稱:go-appengine-mapper,代碼行數:29,代碼來源:warmup.go

示例6: CustomHTTPErrorHandler

func CustomHTTPErrorHandler(err error, c echo.Context) {
	code := http.StatusInternalServerError
	response := ErrResponse{}

	switch v := err.(type) {
	case types.ErrNotFound:
		code = http.StatusNotFound
		response = ErrResponse{"error": v.Error()}
	case types.ErrConflict:
		code = http.StatusConflict
		response = ErrResponse{"error": v.Error()}
	case types.ErrValidation:
		code = http.StatusUnprocessableEntity
		response = ErrResponse{"error": v.Errors}
	case *echo.HTTPError:
		response = ErrResponse{"error": v.Message}
	default:
		response = ErrResponse{"error": v.Error()}
	}

	if !c.Response().Committed {
		if c.Request().Method == echo.HEAD { // Issue #608
			c.NoContent(code)
		} else {
			c.JSON(code, response)
		}
	}
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:28,代碼來源:error.go

示例7: CanSetup

// CanSetup returns StatusOK if able to proceed with setup
func CanSetup(c echo.Context) error {
	db := ToDB(c)
	accts, err := db.GetAccountList()
	if len(accts) > 0 || err != nil {
		return ErrForbidden.Log(err, fmt.Sprintf("total accounts: %s", len(accts)))
	}

	return c.NoContent(200)
}
開發者ID:gogrademe,項目名稱:api,代碼行數:10,代碼來源:setup.go

示例8: CreateCourseTerm

func CreateCourseTerm(c echo.Context) error {
	courseID, _ := strconv.Atoi(c.Param("courseID"))
	termID, _ := strconv.Atoi(c.Param("termID"))

	db := ToDB(c)
	if err := db.InsertCourseTerm(courseID, termID); err != nil {
		return ErrSaving.Log(err)
	}
	return c.NoContent(http.StatusCreated)
}
開發者ID:gogrademe,項目名稱:api,代碼行數:10,代碼來源:course.go

示例9: DeleteLanguage

func DeleteLanguage(c *echo.Context) error {
	languageId := c.Param("id")

	_, err := db.Exec("DELETE FROM languages WHERE id=$1", languageId)

	if err != nil {
		log.Fatal(err)
	}

	return c.NoContent(http.StatusNoContent)
}
開發者ID:ateoto,項目名稱:encounter-tracker-api,代碼行數:11,代碼來源:languages.go

示例10: getHandler

func getHandler(c echo.Context) error {
	key := c.Param("key")

	vs := c.Param("version")
	ts := c.Param("time")

	cfg := c.Get("config").(*Config)

	obj, err := get(cfg, key, true)

	if err != nil {
		return err
	}

	if vs != "" {
		v, err := strconv.Atoi(vs)

		// Invalid parameter for version, treat as a 404.
		if err != nil {
			return c.NoContent(http.StatusNotFound)
		}

		// Version is greater than what is available.
		if v > obj.Version || v < 0 {
			return c.NoContent(http.StatusNotFound)
		}

		obj = obj.AtVersion(v)
	} else if ts != "" {
		t, err := ParseTimeString(ts)

		// Invalid parameter for version, treat as a 404.
		if err != nil {
			return c.NoContent(http.StatusNotFound)
		}

		obj = obj.AtTime(t)

		if obj == nil {
			return c.NoContent(http.StatusNotFound)
		}
	}

	// Does not exist.
	if obj == nil {
		return c.NoContent(http.StatusNoContent)
	}

	// Do not include history in output.
	obj.History = nil

	return c.JSON(http.StatusOK, obj)
}
開發者ID:chop-dbhi,項目名稱:scds,代碼行數:53,代碼來源:http.go

示例11: Delete

func (ee *EventEndpoints) Delete(c echo.Context) error {
	eventID := c.Param("sg_event_id")

	err := ee.DBAdaptor.DeleteEvent(eventID)
	if err != nil {
		return c.JSON(http.StatusInternalServerError, ControllerError{
			Message: err.Error(),
		})
	}

	return c.NoContent(http.StatusOK)
}
開發者ID:efimovalex,項目名稱:EventKitAPI,代碼行數:12,代碼來源:event_endpoints.go

示例12: deleteDestination

func (as ApiService) deleteDestination(c echo.Context) error {
	dst, err := as.balancer.GetDestination(c.Param("destination_name"))
	if err != nil {
		return err
	}

	if err := as.balancer.DeleteDestination(dst); err != nil {
		return err
	}

	return c.NoContent(http.StatusNoContent)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:12,代碼來源:handlers.go

示例13: deleteCheck

func (as ApiService) deleteCheck(c echo.Context) error {
	svcId := c.Param("service_name")
	if _, err := as.balancer.GetService(svcId); err != nil {
		return err
	}

	if err := as.balancer.DeleteCheck(types.CheckSpec{ServiceID: svcId}); err != nil {
		return err
	}

	return c.NoContent(http.StatusNoContent)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:12,代碼來源:handlers.go

示例14: ConditionalDeleteHandler

func (rc *ResourceController) ConditionalDeleteHandler(c *echo.Context) error {
	query := search.Query{Resource: rc.Name, Query: c.Request().URL.RawQuery}
	_, err := rc.DAL.ConditionalDelete(query)
	if err != nil {
		return err
	}

	c.Set("Resource", rc.Name)
	c.Set("Action", "delete")

	c.Response().Header().Set("Access-Control-Allow-Origin", "*")
	return c.NoContent(http.StatusNoContent)
}
開發者ID:intervention-engine,項目名稱:riskservice,代碼行數:13,代碼來源:resource_controller.go

示例15: updateFeed

func (s *APIServer) updateFeed(c echo.Context) error {
	b := new(db.FeedInfo)
	err := jsonapi.UnmarshalPayload(c.Request().Body, b)

	if err != nil {
		return newError(c, "Bad Input", err)
	}
	err = s.DBH.SaveFeed(b)
	if err != nil {
		return newError(c, "Error saving Feed", err)
	}
	return c.NoContent(http.StatusNoContent)
}
開發者ID:hobeone,項目名稱:rss2go,代碼行數:13,代碼來源:server.go


注:本文中的github.com/labstack/echo.Context.NoContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。