server

package
v0.0.0-...-40a75d2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorizeUser

func AuthorizeUser(next http.Handler) http.Handler

AuthorizeUser middleware for validating user token and embed to userinfo to context

func CreateEvent

func CreateEvent(ctx context.Context, msg string, s *ent.Server, u *ent.User) error

func GenerateToken

func GenerateToken(userID string) (string, error)

GenerateToken generate token for user auth

func GenerateTokenCookie

func GenerateTokenCookie(userID string) (*http.Cookie, error)

GenerateTokenCookie generate cookie which includes JWT

func GetServerObject

func GetServerObject(ctx context.Context, s *ent.Server) (*common.ServerObject, error)

GetServerObject Get Server Object by querying db

func GetUser

func GetUser(ctx context.Context) string

GetUser get user from context

func InitRouter

func InitRouter(ctx context.Context, c *config.Configs) *chi.Mux

InitRouter Initialize router

Types

type Server

type Server struct{}

Server dummy routing sturct

func (*Server) AdminCreateTemplate

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

AdminCreateTemplate create template (POST /admin/template)

func (*Server) AdminGetUserList

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

AdminGetUserList get user list (GET /admin/user)

func (*Server) AdminSetQuota

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

AdminSetQuota set user quota (POST /admin/quota) and (POST /admin/quota/{userId})

func (*Server) CreateServer

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

CreateServer Create server request (POST /server)

func (*Server) DeleteServer

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

DeleteServer Delete server (DELETE /server/{serverId}

func (*Server) GetServer

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

GetServer Get server info (GET /server/{serverId}

func (*Server) GetServerList

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

GetServerList Get list of accessible server to user (GET /server)

func (*Server) GetTemplateList

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

GetTemplateList get template list (GET /template)

func (*Server) GetUserInfo

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

GetUserInfo get user info (GET /user)

func (*Server) LoginUser

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

LoginUser Logs in user by set cookie (POST /login)

func (*Server) LogoutUser

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

LogoutUser Log out user by clear cookie (GET /logout)

func (*Server) UpdateUserInfo

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

UpdateUserInfo update user info (POST /user)

Jump to

Keyboard shortcuts

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