PocketBase is an open source Go backend that includes:

  • haveLive subscriptionthe embedded database ( SQLite)
  • built-inFile and User Management
  • convenientAdmin Dashboard UI
  • and simpleREST-ish API

PocketBase canDirect download as a standalone appcan also be used as a Go framework/toolkit, allowing users to build their own custom application specific business logic and still have a portable executable at the end.


# go 1.18+
go get github.com/pocketbase/pocketbase

Example


package main

import (
    "log"
    "net/http"

    "github.com/labstack/echo/v5"
    "github.com/pocketbase/pocketbase"
    "github.com/pocketbase/pocketbase/apis"
    "github.com/pocketbase/pocketbase/core"
)

func main() {
    app := pocketbase.New()

    app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
        // add new "GET /api/hello" route to the app router (echo)
        e.Router.AddRoute(echo.Route{
            Method: http.MethodGet,
            Path:   "/api/hello",
            Handler: func(c echo.Context) error {
                return c.String(200, "Hello world!")
            },
            Middlewares: []echo.MiddlewareFunc{
                apis.RequireAdminOrUserAuth(),
            },
        })

        return nil
    })

    if err := app.Start(); err != nil {
        log.Fatal(err)
    }
}

#PocketBase #Homepage #Documentation #Downloads #Open #Source #Backend #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *