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


Golang Context.RespondWithNotImplemented方法代碼示例

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


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

示例1: Delete

// Delete handles DELETE
func (ctl *ProfileController) Delete(c *models.Context) {
	// Right now no-one can delete as it would break attribution
	// of things like Comments
	c.RespondWithNotImplemented()
	return

	/*
		_, itemTypeID, itemID, status, err := c.GetItemTypeAndItemID()
		if err != nil {
			c.RespondWithErrorDetail(err, status)
		}

		m := models.ProfileType{}
		m.Id = itemID

		status, err := m.Delete()
		if err != nil {
			c.RespondWithErrorDetail(err, status)
			return
		}

		audit.Replace(
			c.Site.ID,
			h.ItemTypes[h.ItemTypeProfile],
			m.Id,
			c.Auth.ProfileID,
			time.Now(),
			c.IP,
		)

		c.RespondWithOK()
	*/
}
開發者ID:riseofthetigers,項目名稱:microcosm,代碼行數:34,代碼來源:profile.go

示例2: Read

func (wc *WhoAmIController) Read(c *models.Context) {

	if c.Request.Method != "GET" {
		c.RespondWithNotImplemented()
		return
	}

	if c.Auth.UserID < 0 {
		c.RespondWithErrorMessage(
			"Bad access token supplied",
			http.StatusForbidden,
		)
		return
	}

	if c.Auth.UserID == 0 {
		c.RespondWithErrorMessage(
			"You must be authenticated to ask 'who am I?'",
			http.StatusForbidden,
		)
		return
	}

	m, status, err := models.GetProfileSummary(c.Site.ID, c.Auth.ProfileID)
	if err != nil {
		if status == http.StatusNotFound {
			c.RespondWithErrorMessage(
				"You must create a user profile for this site at api/v1/profiles/",
				http.StatusNotFound,
			)
			return
		}

		c.RespondWithErrorMessage(
			fmt.Sprintf("Could not retrieve profile: %v", err.Error()),
			http.StatusInternalServerError,
		)
		return
	}

	location := fmt.Sprintf(
		"%s/%d",
		h.APITypeProfile,
		m.ID,
	)

	if c.Auth.ProfileID > 0 && c.Auth.Method == "query" {
		u, _ := url.Parse(location)
		qs := u.Query()
		qs.Del("access_token")
		qs.Add("access_token", c.Auth.AccessToken.TokenValue)
		u.RawQuery = qs.Encode()
		location = u.String()
	}

	c.ResponseWriter.Header().Set("Location", location)
	c.RespondWithStatus(307)
}
開發者ID:riseofthetigers,項目名稱:microcosm,代碼行數:58,代碼來源:whoami.go


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