当前位置: 首页>>代码示例>>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;未经允许,请勿转载。