本文整理汇总了Golang中github.com/convox/rack/api/models.GetService函数的典型用法代码示例。如果您正苦于以下问题:Golang GetService函数的具体用法?Golang GetService怎么用?Golang GetService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetService函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ServiceDelete
func ServiceDelete(rw http.ResponseWriter, r *http.Request) *httperr.Error {
service := mux.Vars(r)["service"]
s, err := models.GetService(service)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such service: %s", service)
}
if err != nil {
return httperr.Server(err)
}
err = s.Delete()
if err != nil {
return httperr.Server(err)
}
s, err = models.GetService(service)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
开发者ID:gisnalbert,项目名称:rack,代码行数:27,代码来源:services.go
示例2: ServiceDelete
func ServiceDelete(rw http.ResponseWriter, r *http.Request) *httperr.Error {
service := mux.Vars(r)["service"]
s, err := models.GetService(service)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such service: %s", service)
}
if err != nil {
return httperr.Server(err)
}
// new services should use the provider interfaces
if s.Type == "syslog" {
s, err := provider.ServiceDelete(service)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
err = s.Delete()
if err != nil {
return httperr.Server(err)
}
s, err = models.GetService(service)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
开发者ID:cleblanc87,项目名称:rack,代码行数:33,代码来源:services.go
示例3: ServiceDelete
func ServiceDelete(rw http.ResponseWriter, r *http.Request) error {
service := mux.Vars(r)["service"]
s, err := models.GetService(service)
if awsError(err) == "ValidationError" {
return RenderNotFound(rw, fmt.Sprintf("no such service: %s", service))
}
if err != nil {
return err
}
err = s.Delete()
if err != nil {
return err
}
s, err = models.GetService(service)
if err != nil {
return err
}
return RenderJson(rw, s)
}
开发者ID:jbuck,项目名称:rack,代码行数:27,代码来源:services.go
示例4: ServiceCreate
func ServiceCreate(rw http.ResponseWriter, r *http.Request) error {
name := GetForm(r, "name")
t := GetForm(r, "type")
service := &models.Service{
Name: name,
Type: t,
}
err := service.Create()
if awsError(err) == "ValidationError" {
return RenderForbidden(rw, fmt.Sprintf("invalid service name: %s", name))
}
if err != nil {
return err
}
service, err = models.GetService(name)
if err != nil {
return err
}
return RenderJson(rw, service)
}
开发者ID:jbuck,项目名称:rack,代码行数:27,代码来源:services.go
示例5: ServiceUpdate
func ServiceUpdate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
service := mux.Vars(r)["service"]
s, err := models.GetService(service)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such service: %s", service)
}
if err != nil {
return httperr.Server(err)
}
err = r.ParseForm()
if err != nil {
return httperr.Server(err)
}
// get the last set value for all form values
// ie: foo=1&foo=2 sets foo to "2"
params := make(map[string]string)
for key, values := range r.Form {
val := values[len(values)-1]
params[key] = val
}
err = s.Update(models.CFParams(params))
if err != nil && awsError(err) == "ValidationError" {
e := err.(awserr.Error)
return httperr.Errorf(403, convoxifyCloudformationError(e.Message()))
}
if err != nil {
return httperr.Server(err)
}
s, err = models.GetService(service)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
开发者ID:cleblanc87,项目名称:rack,代码行数:45,代码来源:services.go
示例6: ServiceCreate
func ServiceCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
err := r.ParseForm()
if err != nil {
return httperr.Server(err)
}
// get the last set value for all form values
// ie: foo=1&foo=2 sets foo to "2"
params := make(map[string]string)
for key, values := range r.Form {
val := values[len(values)-1]
params[key] = val
}
name := params["name"]
delete(params, "name")
kind := params["type"]
delete(params, "type")
// Early check for unbound service only.
service, err := models.GetServiceUnbound(name)
if err == nil {
return httperr.Errorf(403, "there is already a legacy service named %s (%s). We recommend you delete this service and create it again.", name, service.Status)
}
if awsError(err) == "ValidationError" {
// If unbound check fails this will result in a bound service.
service = &models.Service{
Name: name,
Type: kind,
Parameters: models.CFParams(params),
}
}
err = service.Create()
if err != nil && strings.HasSuffix(err.Error(), "not found") {
return httperr.Errorf(403, "invalid service type: %s", kind)
}
if err != nil && awsError(err) == "ValidationError" {
e := err.(awserr.Error)
return httperr.Errorf(403, convoxifyCloudformationError(e.Message()))
}
if err != nil {
return httperr.Server(err)
}
service, err = models.GetService(name)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, service)
}
开发者ID:soulware,项目名称:rack,代码行数:57,代码来源:services.go
示例7: LinkCreate
func LinkCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
service := mux.Vars(r)["service"]
s, err := models.GetService(service)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such service: %s", service)
}
if err != nil {
return httperr.Server(err)
}
if s.Status != "running" {
return httperr.Errorf(403, "can not link service with status: %s", s.Status)
}
// new services should use the provider interfaces
if s.Type == "syslog" {
s, err := provider.ServiceLink(service, GetForm(r, "app"), GetForm(r, "process"))
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
if s.Type != "papertrail" {
return httperr.Errorf(403, "linking is not yet implemented for service type: %s", s.Type)
}
app := GetForm(r, "app")
a, err := models.GetApp(app)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such app: %s", app)
}
if err != nil {
return httperr.Server(err)
}
err = s.LinkPapertrail(*a)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
开发者ID:cleblanc87,项目名称:rack,代码行数:49,代码来源:links.go
示例8: ServiceCreate
func ServiceCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
err := r.ParseForm()
if err != nil {
return httperr.Server(err)
}
// get the last set value for all form values
// ie: foo=1&foo=2 sets foo to "2"
params := make(map[string]string)
for key, values := range r.Form {
val := values[len(values)-1]
params[key] = val
}
name := params["name"]
delete(params, "name")
kind := params["type"]
delete(params, "type")
service := &models.Service{
Name: name,
Type: kind,
Parameters: models.CFParams(params),
}
err = service.Create()
if err != nil && strings.HasSuffix(err.Error(), "not found") {
return httperr.Errorf(403, "invalid service type: %s", kind)
}
if err != nil && awsError(err) == "ValidationError" {
e := err.(awserr.Error)
return httperr.Errorf(403, convoxifyCloudformationError(e.Message()))
}
if err != nil {
return httperr.Server(err)
}
service, err = models.GetService(name)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, service)
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:47,代码来源:services.go
示例9: ServiceCreate
func ServiceCreate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
name := GetForm(r, "name")
t := GetForm(r, "type")
url := GetForm(r, "url")
service := &models.Service{
Name: name,
Type: t,
URL: url,
}
var err error
switch t {
case "papertrail":
err = service.CreatePapertrail()
case "webhook":
err = service.CreateWebhook()
default:
err = service.CreateDatastore()
}
if err != nil && strings.HasSuffix(err.Error(), "not found") {
return httperr.Errorf(403, "invalid service type: %s", t)
}
if err != nil && awsError(err) == "ValidationError" {
return httperr.Errorf(403, "invalid service name: %s", name)
}
if err != nil {
return httperr.Server(err)
}
service, err = models.GetService(name)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, service)
}
开发者ID:gisnalbert,项目名称:rack,代码行数:42,代码来源:services.go
示例10: ServiceLogs
func ServiceLogs(ws *websocket.Conn) error {
service := mux.Vars(ws.Request())["service"]
s, err := models.GetService(service)
if err != nil {
return err
}
logs := make(chan []byte)
done := make(chan bool)
s.SubscribeLogs(logs, done)
for data := range logs {
ws.Write(data)
}
return nil
}
开发者ID:harryross,项目名称:rack,代码行数:20,代码来源:services.go
示例11: LinkDelete
func LinkDelete(rw http.ResponseWriter, r *http.Request) *httperr.Error {
app := mux.Vars(r)["app"]
service := mux.Vars(r)["service"]
s, err := models.GetService(service)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such service: %s", service)
}
if err != nil {
return httperr.Server(err)
}
if s.Status != "running" {
return httperr.Errorf(403, "can not unlink service with status: %s", s.Status)
}
if s.Type != "papertrail" {
return httperr.Errorf(403, "unlinking is not yet implemented for service type: %s", s.Type)
}
a, err := models.GetApp(app)
if awsError(err) == "ValidationError" {
return httperr.Errorf(404, "no such app: %s", app)
}
if err != nil {
return httperr.Server(err)
}
err = s.UnlinkPapertrail(*a)
if err != nil {
return httperr.Server(err)
}
return RenderJson(rw, s)
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:40,代码来源:links.go
示例12: ServiceLogs
func ServiceLogs(ws *websocket.Conn) *httperr.Error {
service := mux.Vars(ws.Request())["service"]
s, err := models.GetService(service)
if err != nil {
return httperr.Server(err)
}
logs := make(chan []byte)
done := make(chan bool)
s.SubscribeLogs(logs, done)
go signalWsClose(ws, done)
for data := range logs {
ws.Write(data)
}
return nil
}
开发者ID:gisnalbert,项目名称:rack,代码行数:22,代码来源:services.go
注:本文中的github.com/convox/rack/api/models.GetService函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论