ui

package
v0.0.0-...-3dd2d23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, client service.ConsensusClient, logger *slog.Logger) error

Run starts the HTTP server and serves the static files and the index page. It takes an address as a parameter, which is the address on which the server should listen for incoming requests. The address should be in the format `host:port`.

Returns an error if there was a problem starting the server.

func LoggedInRedirector

func LoggedInRedirector(next http.Handler) http.Handler

func UnloggedInRedirector

func UnloggedInRedirector(next http.Handler) http.Handler

Types

type Card

type Card struct {
	ID      int64
	Title   string
	Content string
}

type JWT

type JWT struct {
	ID        string    `json:"jti"`  // JWT ID is a unique identifier to prevent replay attacks
	Audience  []string  `json:"aud"`  // Audience is the intended recipient of the JWT
	Subject   int64     `json:"sub"`  // Subject which can be used to identify the user, e.g. user id
	IssuedAt  time.Time `json:"iat"`  // IssuedAt is the time at which the JWT was issued
	ExpiresAt time.Time `json:"exp"`  // ExpiresAt is the time at which the JWT will expire
	User      User      `json:"user"` // User is the user associated with the JWT
}

JWT represents a JSON Web Token

func JWTFromCtx

func JWTFromCtx(ctx context.Context) (JWT, error)

JWTFromCtx is a helper function to get the JWT from the context

func JWTFromMap

func JWTFromMap(m map[string]any) (JWT, error)

JWTFromMap is a helper function to convert a map to a JWT

func (JWT) AsMap

func (j JWT) AsMap() map[string]any

AsMap is a helper function to convert a JWT to a map

type Payload

type Payload struct {
	Project Project
	JWT     JWT
}

Payload is the main page payload

type Project

type Project struct {
	ID          int64
	Title       string
	Description string
	Backlog     []Card
	InProgress  []Card
	CodeReview  []Card
	Testing     []Card
	Done        []Card
	Owner       User
}

func CoreProjectToProject

func CoreProjectToProject(project *service.Project) Project

CoreProjectToProject converts a core project to a project.

func CoreProjectsToProjects

func CoreProjectsToProjects(projects ...*service.Project) []Project

CoreProjectsToProjects converts a one or more core projects to one or more projects.

type User

type User struct {
	ID        int64  `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Role      string `json:"role"`
}

func CoreUserToUser

func CoreUserToUser(user *service.User) User

CoreUserToUser converts a core user to a user.

func CoreUsersToUsers

func CoreUsersToUsers(users ...*service.User) []User

CoreUsersToUsers converts a one or more core users to one or more users.

Jump to

Keyboard shortcuts

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