server

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginRequest

type LoginRequest struct {
	AccessKey   string `json:"accessKey"`
	SecretKey   string `json:"secretKey"`
	Environment string `json:"environment"` // staging, production, dev
}

LoginRequest represents the login credentials

type LoginResponse

type LoginResponse struct {
	SessionToken string `json:"sessionToken"`
	ExpiresIn    int64  `json:"expiresIn"` // seconds
	Environment  string `json:"environment"`
}

LoginResponse represents the login response

type LogoutRequest

type LogoutRequest struct {
	SessionToken string `json:"sessionToken"`
}

LogoutRequest represents the logout request

type MegaportAuthResponse

type MegaportAuthResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

MegaportAuthResponse represents Megaport API token response

type Server

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

Server represents the WASM HTTP server with session management

func NewServer

func NewServer(sessionDuration time.Duration, logger *log.Logger) *Server

NewServer creates a new server instance

func (*Server) GetSessionManager

func (s *Server) GetSessionManager() *SessionManager

GetSessionManager returns the session manager

func (*Server) HandleLogin

func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request)

HandleLogin handles customer login requests

func (*Server) HandleLogout

func (s *Server) HandleLogout(w http.ResponseWriter, r *http.Request)

HandleLogout handles customer logout requests

func (*Server) HandleSessionCheck

func (s *Server) HandleSessionCheck(w http.ResponseWriter, r *http.Request)

HandleSessionCheck checks if a session is valid

type Session

type Session struct {
	ID            string
	AccessKey     string
	SecretKey     string
	MegaportToken string
	TokenExpiry   time.Time
	CreatedAt     time.Time
	ExpiresAt     time.Time
	LastActivity  time.Time
}

Session represents a customer's authenticated session

type SessionManager

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

SessionManager manages customer sessions

func NewSessionManager

func NewSessionManager(sessionDuration time.Duration) *SessionManager

NewSessionManager creates a new session manager

func (*SessionManager) CreateSession

func (sm *SessionManager) CreateSession(accessKey, secretKey string) (*Session, error)

CreateSession creates a new session for a customer

func (*SessionManager) DeleteSession

func (sm *SessionManager) DeleteSession(sessionID string)

DeleteSession removes a session (logout)

func (*SessionManager) GetSession

func (sm *SessionManager) GetSession(sessionID string) *Session

GetSession retrieves a session by ID

func (*SessionManager) GetSessionCount

func (sm *SessionManager) GetSessionCount() int

GetSessionCount returns the number of active sessions

func (*SessionManager) UpdateActivity

func (sm *SessionManager) UpdateActivity(sessionID string)

UpdateActivity updates the last activity time for a session

func (*SessionManager) UpdateMegaportToken

func (sm *SessionManager) UpdateMegaportToken(sessionID, token string, expiry time.Time)

UpdateMegaportToken updates the Megaport API token for a session

Jump to

Keyboard shortcuts

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