本文整理汇总了Golang中github.com/labstack/echo.Context.P方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.P方法的具体用法?Golang Context.P怎么用?Golang Context.P使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/labstack/echo.Context
的用法示例。
在下文中一共展示了Context.P方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ProjectGetOne
func ProjectGetOne(ctx *echo.Context) error {
interactor := ctx.Get("ProjectInteractor").(*usecases.ProjectInteractor)
projId := ctx.P(0)
result := interactor.GetOne(projId)
return ctx.JSON(http.StatusOK, result)
}
示例2: EnvironmentGetOne
func EnvironmentGetOne(ctx *echo.Context) error {
interactor := ctx.Get("EnvironmentInteractor").(*usecases.EnvironmentInteractor)
envId := ctx.P(0)
result := interactor.GetEnvironmentById(envId)
return ctx.JSON(http.StatusOK, result)
}
示例3: RenderStatic
func RenderStatic(c echo.Context) error {
a, err := Asset(fmt.Sprintf("static%s", c.P(0)))
if err != nil {
panic(err)
}
return c.String(http.StatusOK, string(a))
}
示例4: GetOne
// GetOne tag
func (*TagsController) GetOne(c echo.Context) error {
var model models.Tag
ret, err := model.GetOne(c.P(0))
if err != nil {
return c.JSON(400, utils.ErrMarshal(err.Error()))
}
return c.JSON(200, ret)
}
示例5: Single
// Single shows single page
func (*SiteController) Single(c echo.Context) error {
var site models.Site
ret, err := site.Single(c.P(0))
if err != nil {
return c.Render(400, "404", err)
}
return c.Render(200, "index", ret)
}
示例6: GetTokenLinks
func GetTokenLinks(c echo.Context) error {
userToken := c.P(0)
matchSpecific := func(b string) bool {
return b == userToken
}
linksResponse, err := getTokenLinks(matchSpecific, uriBuilder(c))
if err != nil {
return err
}
return c.JSON(http.StatusOK, linksResponse)
}
示例7: UserUpdate
func UserUpdate(ctx *echo.Context) error {
interactor := ctx.Get("UserInteractor").(*usecases.UserInteractor)
user := &entities.User{}
if err := ctx.Bind(user); err != nil {
return ctx.JSON(http.StatusBadRequest, "user: unable to parse")
}
user.Id = ctx.P(0)
result := interactor.Update(user)
return ctx.JSON(http.StatusOK, result)
}
示例8: EditHandlerPost
func EditHandlerPost(c echo.Context) error {
filepath := c.P(0)
eolIndex, _ := strconv.Atoi(c.FormValue("eol"))
content := c.FormValue("content")
convertedContent, err := eol.LineEnding(eolIndex).Apply(content)
if err != nil {
convertedContent = content
log.Println("Error while converting EOL. Saving without conversion.")
}
ioutil.WriteFile(filepath, []byte(convertedContent), 0644)
c.Set("editorView", NewEditorView(filepath, content))
return EditHandler(c)
}
示例9: ProjectUpdate
func ProjectUpdate(ctx *echo.Context) error {
interactor := ctx.Get("ProjectInteractor").(*usecases.ProjectInteractor)
projId := ctx.P(0)
proj := interactor.GetOne(projId)
if err := ctx.Bind(proj); err != nil {
return ctx.JSON(http.StatusBadRequest, "project: unable to parse")
}
result := interactor.Update(proj)
return ctx.JSON(http.StatusOK, result)
}
示例10: Get
// Find one app
func (r App) Get(c *echo.Context, s *dokku.Dokku) error {
name := c.P(0)
app, err := s.Apps.Find(name)
if err != nil {
return err
}
if app == nil {
return c.NoContent(http.StatusNotFound)
}
return c.JSONIndent(http.StatusOK, app, "", " ")
}
示例11: EnvironmentUpdate
func EnvironmentUpdate(ctx *echo.Context) error {
interactor := ctx.Get("EnvironmentInteractor").(*usecases.EnvironmentInteractor)
envId := ctx.P(0)
env := interactor.GetEnvironmentById(envId)
if err := ctx.Bind(env); err != nil {
return ctx.JSON(http.StatusBadRequest, "environment: unable to parse")
}
result := interactor.Update(env)
return ctx.JSON(http.StatusOK, result)
}
示例12: DownloadFile
func DownloadFile(c echo.Context) error {
fileToken := c.P(0)
src, err := persistence.FindFile([]byte(fileToken))
if err != nil {
return err
}
defer src.Close()
res := c.Response()
if _, err := io.Copy(res.Writer(), src); err != nil {
return err
}
return nil
}
示例13: EditHandler
func EditHandler(c echo.Context) error {
var ev *EditorView
ev, ok := c.Get("editorView").(*EditorView)
if !ok {
log.Println("reading file")
filepath := c.P(0)
content, err := ioutil.ReadFile(filepath)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Unable to read requested file")
}
ev = NewEditorView(filepath, string(content))
ev.CurrentLineEnding = eol.DetectDefault(ev.Content, eol.OSDefault())
log.Println(ev.CurrentLineEnding.Description())
}
return c.Render(http.StatusOK, "base", ev)
}
示例14: Update
// Update tag
func (*TagsController) Update(c echo.Context) error {
var model models.Tag
var payload models.Tag
if err := c.Bind(&payload); err != nil {
return c.JSON(400, utils.ErrMarshal(err.Error()))
}
iss := 1
payload.UpdatedBy = iss
ret, err := model.Update(c.P(0), payload)
if err != nil {
return c.JSON(400, utils.ErrMarshal(err.Error()))
}
return c.JSON(200, ret)
}
示例15: Update
// Update post
func (*PostsController) Update(c echo.Context) error {
var model models.Post
var payload models.PostPayload
var status = c.QueryParam("status")
if err := c.Bind(&payload); err != nil {
return c.JSON(400, utils.ErrMarshal(err.Error()))
}
iss := 1
payload.UpdatedBy = iss
ret, err := model.Update(c.P(0), payload, status)
if err != nil {
return c.JSON(400, utils.ErrMarshal(err.Error()))
}
return c.JSON(200, ret)
}