echopop

package
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package echopop adds middleware functions to projects using the Invopop API and the Echo v4 web framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthEnrollment

func AuthEnrollment(ic *invopop.Client) echo.MiddlewareFunc

AuthEnrollment defines a middleware function that will authenticate an enrollment with the Invopop API. This middleware will only work if the invopop client has been prepared using the OAuth Client ID and Secret.

This method supports tokens provided either via the "Authorization" header, or a "state" query parameter, and is meant to be used by applications that offer a web interface via the Invopop Console.

Enrollments authorized in this way will include a new token with additional scopes that can be used to access restricted functionality like updating the embedded enrollment data or accessing silo entry meta rows.

func GetClient

func GetClient(c echo.Context) *invopop.Client

GetClient provides the Invopop client that was prepared with the enrollment's auth token.

func GetEnrollment

func GetEnrollment(c echo.Context) *invopop.Enrollment

GetEnrollment retrieves the enrollment object from the context.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides a wrapper around Echo that makes it a bit easier to start up a new service that will provide an HTTP server.

func NewService

func NewService() *Service

NewService instantiates a new echo service using some reasonable defaults.

func (*Service) Render

func (s *Service) Render(name, src string, fs embed.FS)

Render will prepare the echo templating feature using "goview" and the recommended defaults for modules.

If the source file path is not found, it'll attempt to use the provided filesystem object. Assets served from disk will have caching disabled to facilitate rapid reloading.

Usage example:

m.Render("templates", "./assets", assets.Content)

Where the name ("templates") defines the path inside the source assets folder ("./assets") to find the data, *or* if not available, use the `assets.Content` embedded filesystem.

func (*Service) Root

func (s *Service) Root(fn func(*echo.Group))

Root provides an Echo Group instance from which to serve HTTP requests.

func (*Service) Serve

func (s *Service) Serve(fn func(*echo.Echo))

Serve provides the echo instance in a callback method which might be semantically useful, but doesn't do much.

func (*Service) Start

func (s *Service) Start(port string) error

Start will start the service on the provided port in the foreground.

func (*Service) StaticRootFS

func (s *Service) StaticRootFS(fs fs.FS, root string)

StaticRootFS is used to serve static file assets from the web folder root. The root is the path to the folder in the filesystem, and the fs is the filesystem object to use.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop will gracefully stop the service with the passed context that probably includes a timeout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL