本文整理汇总了Golang中github.com/cloudsecurityalliance/ctpd/server/ctp.NewHttpError函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHttpError函数的具体用法?Golang NewHttpError怎么用?Golang NewHttpError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewHttpError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Create
func (asset *Asset) Create(context *ctp.ApiContext) *ctp.HttpError {
asset.BuildLinks(context)
if !ctp.CreateResource(context, "assets", asset) {
return ctp.NewHttpError(http.StatusInternalServerError, "Could not save asset")
}
return nil
}
示例2: Create
func (attribute *Attribute) Create(context *ctp.ApiContext) *ctp.HttpError {
attribute.BuildLinks(context)
if !ctp.CreateResource(context, "attributes", attribute) {
return ctp.NewHttpError(http.StatusInternalServerError, "Could not save object")
}
return nil
}
示例3: Load
func (res *TaggedResource) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, context.Params[0], ctp.Base64Id(context.Params[1]), res) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
res.BuildLinks(context)
return nil
}
示例4: Load
func (attribute *Attribute) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "attributes", ctp.Base64Id(context.Params[1]), attribute) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
attribute.BuildLinks(context)
return nil
}
示例5: Create
func (account *Account) Create(context *ctp.ApiContext) *ctp.HttpError {
var key [24]byte
account.BuildLinks(context)
if account.Token == "" {
_, err := rand.Read(key[:])
if err != nil {
return ctp.NewInternalServerError("Error generating key")
}
account.Token = base64.StdEncoding.EncodeToString(key[:])
}
if len(account.AccountTags.WithPrefix("account:")) == 0 {
account.AccountTags.Append(ctp.NewTags("account:" + string(account.Id)))
}
if len(account.AccountTags.WithPrefix("role:")) == 0 {
account.AccountTags.Append(ctp.UserRoleTag)
}
if !ctp.CreateResource(context, "accounts", account) {
return ctp.NewHttpError(http.StatusInternalServerError, "Could not save account")
}
return nil
}
示例6: Load
func (serviceview *ServiceView) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "serviceViews", ctp.Base64Id(context.Params[1]), serviceview) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
serviceview.BuildLinks(context)
return nil
}
示例7: Load
func (log *LogEntry) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "logs", ctp.Base64Id(context.Params[1]), log) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
log.BuildLinks(context)
return nil
}
示例8: Load
func (metric *Metric) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "metrics", ctp.Base64Id(context.Params[1]), metric) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
metric.BuildLinks(context)
return nil
}
示例9: Load
func (asset *Asset) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "assets", ctp.Base64Id(context.Params[1]), asset) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
asset.BuildLinks(context)
return nil
}
示例10: Load
func (access *Access) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "access", ctp.Base64Id(context.Params[1]), access) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
access.BuildLinks(context)
return nil
}
示例11: Load
func (trigger *Trigger) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "triggers", ctp.Base64Id(context.Params[1]), trigger) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
trigger.Measurement = ctp.ExpandLink(context.CtpBase, trigger.Measurement)
trigger.BuildLinks(context)
return nil
}
示例12: Create
func (log *LogEntry) Create(context *ctp.ApiContext) *ctp.HttpError {
log.BuildLinks(context)
//log.CreationTime = ctp.Now()
if !ctp.CreateResource(context, "logs", log) {
return ctp.NewHttpError(http.StatusInternalServerError, "Could not save object")
}
return nil
}
示例13: Create
func (serviceview *ServiceView) Create(context *ctp.ApiContext) *ctp.HttpError {
serviceview.BuildLinks(context)
if !ctp.CreateResource(context, "serviceViews", serviceview) {
return ctp.NewHttpError(http.StatusInternalServerError, "Could not save object")
}
return nil
}
示例14: Load
func (measurement *Measurement) Load(context *ctp.ApiContext) *ctp.HttpError {
if !ctp.LoadResource(context, "measurements", ctp.Base64Id(context.Params[1]), measurement) {
return ctp.NewHttpError(http.StatusNotFound, "Not Found")
}
measurement.Metric = ctp.ExpandLink(context.CtpBase, measurement.Metric)
measurement.BuildLinks(context)
return nil
}
示例15: Create
func (metric *Metric) Create(context *ctp.ApiContext) *ctp.HttpError {
metric.BuildLinks(context)
if !ctp.CreateResource(context, "metrics", metric) {
return ctp.NewHttpError(http.StatusInternalServerError, "Could not save object")
}
return nil
}