handlers

package
v0.0.0-...-f68b460 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateChat

func CreateChat(w http.ResponseWriter, r *http.Request)

CreateChat creates a new chat for the current user

func CreateUser

func CreateUser(w http.ResponseWriter, r *http.Request)

CreateUser creates a new user (admin only)

func DeleteAPIKey

func DeleteAPIKey(w http.ResponseWriter, r *http.Request)

func DeleteChat

func DeleteChat(w http.ResponseWriter, r *http.Request)

DeleteChat deletes a chat for the current user

func DeleteUser

func DeleteUser(w http.ResponseWriter, r *http.Request)

func GenerateAPIKey

func GenerateAPIKey(w http.ResponseWriter, r *http.Request)

GenerateAPIKey creates a new API key for the authenticated user

func GetAdminSettings

func GetAdminSettings(w http.ResponseWriter, r *http.Request)

func GetChats

func GetChats(w http.ResponseWriter, r *http.Request)

GetChats returns all chats for the current user

func GetCurrentUser

func GetCurrentUser(w http.ResponseWriter, r *http.Request)

GetCurrentUser returns the current authenticated user's information

func InitHandlers

func InitHandlers(db *db.DB)

InitHandlers initializes the handlers with a database connection

func ListUsers

func ListUsers(w http.ResponseWriter, r *http.Request)

ListUsers returns a list of all users (admin only)

func Login

func Login(w http.ResponseWriter, r *http.Request)

Login handles user login requests

func Logout

func Logout(w http.ResponseWriter, r *http.Request)

Logout handles user logout

func RefreshToken

func RefreshToken(w http.ResponseWriter, r *http.Request)

RefreshToken handles token refresh requests

func Signup

func Signup(w http.ResponseWriter, r *http.Request)

Signup handles user registration

func UpdateAdminSettings

func UpdateAdminSettings(w http.ResponseWriter, r *http.Request)

func UpdateUser

func UpdateUser(w http.ResponseWriter, r *http.Request)

func UpdateUserSettings

func UpdateUserSettings(w http.ResponseWriter, r *http.Request)

Types

type APIKeyResponse

type APIKeyResponse struct {
	APIKey string `json:"api_key"`
}

APIKeyResponse represents an API key response

type ChatSummary

type ChatSummary struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}

ChatSummary represents a summary of a chat

type CreateUserRequest

type CreateUserRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	IsAdmin  bool   `json:"is_admin"`
}

CreateUserRequest represents a request to create a new user

type LoginRequest

type LoginRequest struct {
	Email      string `json:"email"`
	Password   string `json:"password"`
	RememberMe bool   `json:"remember_me"`
}

LoginRequest represents a login request

type LoginResponse

type LoginResponse struct {
	Token        string                `json:"token"`
	RefreshToken string                `json:"refresh_token,omitempty"`
	UserID       int                   `json:"user_id"`
	IsAdmin      bool                  `json:"is_admin"`
	Settings     settings.UserSettings `json:"settings"`
}

LoginResponse represents a login response

type SignupRequest

type SignupRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

SignupRequest represents a signup request

type UpdateUserSettingsRequest

type UpdateUserSettingsRequest struct {
	Settings settings.UserSettings `json:"settings"`
}

UpdateUserSettingsRequest represents the request body for updating user settings

type UserResponse

type UserResponse struct {
	ID       int                   `json:"id"`
	Email    string                `json:"email"`
	IsAdmin  bool                  `json:"is_admin"`
	IsSso    bool                  `json:"is_sso"`
	Settings settings.UserSettings `json:"settings"`
}

UserResponse represents a user response with sensitive fields removed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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