server

package
v0.0.0-...-7f4b9de Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package server provides primitives to interact the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

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 DecryptRegisterToken

func DecryptRegisterToken(token string) (userID, email string, err error)

func GenerateNewToken

func GenerateNewToken() string

GenerateNewToken 임의의 토큰을 생성해서 반환한다.

func GenerateRegisterToken

func GenerateRegisterToken(userID, eamil string) (string, 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 GetSwagger

func GetSwagger() (*openapi3.Swagger, error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file.

func GetUser

func GetUser(ctx context.Context) string

GetUser get user from context

func GetUserObject

func GetUserObject(ctx context.Context) (*ent.User, error)

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func Init

func Init(ctx context.Context) *chi.Mux

Init initialize router

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL     string
	BaseRouter  chi.Router
	Middlewares []MiddlewareFunc
}

type ClientInfo

type ClientInfo struct {

	// identification of client
	ClientID *int `json:"clientID,omitempty"`

	// name of the client
	ClientName  string  `json:"clientName"`
	Description string  `json:"description"`
	Link        string  `json:"link"`
	Token       *string `json:"token,omitempty"`
	Valid       bool    `json:"valid"`
}

ClientInfo defines model for ClientInfo.

func (*ClientInfo) Bind

func (v *ClientInfo) Bind(r *http.Request) error

type CreateClientJSONBody

type CreateClientJSONBody CreateClientRequest

CreateClientJSONBody defines parameters for CreateClient.

type CreateClientJSONRequestBody

type CreateClientJSONRequestBody CreateClientJSONBody

CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType.

type CreateClientRequest

type CreateClientRequest struct {
	// Embedded struct due to allOf(#/components/schemas/ClientInfo)
	ClientInfo `yaml:",inline"`
}

CreateClientRequest defines model for CreateClientRequest.

type CreateUserJSONBody

type CreateUserJSONBody CreateUserRequest

CreateUserJSONBody defines parameters for CreateUser.

type CreateUserJSONRequestBody

type CreateUserJSONRequestBody CreateUserJSONBody

CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.

type CreateUserRequest

type CreateUserRequest struct {
	// Embedded struct due to allOf(#/components/schemas/UserInfo)
	UserInfo `yaml:",inline"`

	// token sent by email
	Token string `json:"token"`
}

CreateUserRequest defines model for CreateUserRequest.

func (*CreateUserRequest) Bind

func (v *CreateUserRequest) Bind(r *http.Request) error

type GetUserInfoByClientTokenJSONBody

type GetUserInfoByClientTokenJSONBody struct {

	// client token to auth
	Token string `json:"token"`

	// userID to get user info
	UserID string `json:"userID"`

	// userPW to get user info
	UserPW string `json:"userPW"`
}

GetUserInfoByClientTokenJSONBody defines parameters for GetUserInfoByClientToken.

func (*GetUserInfoByClientTokenJSONBody) Bind

type GetUserInfoByClientTokenJSONRequestBody

type GetUserInfoByClientTokenJSONRequestBody GetUserInfoByClientTokenJSONBody

GetUserInfoByClientTokenJSONRequestBody defines body for GetUserInfoByClientToken for application/json ContentType.

type LoginRequest

type LoginRequest struct {
	UserID string `json:"userID"`
	UserPW string `json:"userPW"`
}

LoginRequest defines model for LoginRequest.

func (*LoginRequest) Bind

func (v *LoginRequest) Bind(r *http.Request) error

type LoginUserJSONBody

type LoginUserJSONBody LoginRequest

LoginUserJSONBody defines parameters for LoginUser.

type LoginUserJSONRequestBody

type LoginUserJSONRequestBody LoginUserJSONBody

LoginUserJSONRequestBody defines body for LoginUser for application/json ContentType.

type Logs

type Logs []struct {

	// event type
	Event string `json:"event"`

	// event time
	Time string `json:"time"`
}

Logs defines model for Logs.

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type Reason

type Reason struct {
	Reason string `json:"reason"`
}

Reason defines model for Reason.

func GetReason

func GetReason(format string, a ...interface{}) Reason

GetReason return string format to Reason struct

type RequestToken

type RequestToken struct {

	// email address to send token
	Email string `json:"email"`

	// userID to sign the token
	UserID string `json:"userID"`
}

RequestToken defines model for RequestToken.

func (*RequestToken) Bind

func (v *RequestToken) Bind(r *http.Request) error

type RequestTokenJSONBody

type RequestTokenJSONBody RequestToken

RequestTokenJSONBody defines parameters for RequestToken.

type RequestTokenJSONRequestBody

type RequestTokenJSONRequestBody RequestTokenJSONBody

RequestTokenJSONRequestBody defines body for RequestToken for application/json ContentType.

type Server

type Server struct{}

Server base server struct

func (Server) CreateClient

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

CreateClient request for registration (PUT /v1/client)

func (Server) CreateUser

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

CreateUser request for registration (PUT /v1/user)

func (Server) DeleteClient

func (s Server) DeleteClient(w http.ResponseWriter, r *http.Request, clientID string)

DeleteClient delete client (DELETE /v1/client/{clientID})

func (Server) GetClientList

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

GetClientList get client info (GET /v1/client)

func (Server) GetUser

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

GetUser get user info (GET /v1/user)

func (Server) GetUserInfoByClientToken

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

GetUserInfoByClientToken get user info with client token (POST /v1/client/user)

func (Server) GetUserLogs

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

GetUserLogs get login history for user (GET /v1/logs)

func (Server) LoginUser

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

LoginUser Logs in user (POST /v1/login)

func (Server) LogoutUser

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

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

func (Server) PingPong

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

PingPong ping check (GET /v1/ping)

func (Server) RequestToken

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

RequestToken request token for registration (POST /v1/token)

func (Server) UpdateUser

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

UpdateUser update user info (POST /v1/user)

type ServerInterface

type ServerInterface interface {
	// get client list
	// (GET /v1/client)
	GetClientList(w http.ResponseWriter, r *http.Request)
	// request for registration
	// (PUT /v1/client)
	CreateClient(w http.ResponseWriter, r *http.Request)
	// get user info with client token
	// (POST /v1/client/user)
	GetUserInfoByClientToken(w http.ResponseWriter, r *http.Request)
	// delete client
	// (DELETE /v1/client/{clientID})
	DeleteClient(w http.ResponseWriter, r *http.Request, clientID string)
	// Logs in user
	// (POST /v1/login)
	LoginUser(w http.ResponseWriter, r *http.Request)
	// Log out user by clear cookie
	// (GET /v1/logout)
	LogoutUser(w http.ResponseWriter, r *http.Request)
	// get login history for user
	// (GET /v1/logs)
	GetUserLogs(w http.ResponseWriter, r *http.Request)
	// ping check
	// (GET /v1/ping)
	PingPong(w http.ResponseWriter, r *http.Request)
	// request token for registration
	// (POST /v1/token)
	RequestToken(w http.ResponseWriter, r *http.Request)
	// get user info
	// (GET /v1/user)
	GetUser(w http.ResponseWriter, r *http.Request)
	// update user info
	// (POST /v1/user)
	UpdateUser(w http.ResponseWriter, r *http.Request)
	// request for registration
	// (PUT /v1/user)
	CreateUser(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateClient

func (siw *ServerInterfaceWrapper) CreateClient(w http.ResponseWriter, r *http.Request)

CreateClient operation middleware

func (*ServerInterfaceWrapper) CreateUser

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

CreateUser operation middleware

func (*ServerInterfaceWrapper) DeleteClient

func (siw *ServerInterfaceWrapper) DeleteClient(w http.ResponseWriter, r *http.Request)

DeleteClient operation middleware

func (*ServerInterfaceWrapper) GetClientList

func (siw *ServerInterfaceWrapper) GetClientList(w http.ResponseWriter, r *http.Request)

GetClientList operation middleware

func (*ServerInterfaceWrapper) GetUser

GetUser operation middleware

func (*ServerInterfaceWrapper) GetUserInfoByClientToken

func (siw *ServerInterfaceWrapper) GetUserInfoByClientToken(w http.ResponseWriter, r *http.Request)

GetUserInfoByClientToken operation middleware

func (*ServerInterfaceWrapper) GetUserLogs

func (siw *ServerInterfaceWrapper) GetUserLogs(w http.ResponseWriter, r *http.Request)

GetUserLogs operation middleware

func (*ServerInterfaceWrapper) LoginUser

func (siw *ServerInterfaceWrapper) LoginUser(w http.ResponseWriter, r *http.Request)

LoginUser operation middleware

func (*ServerInterfaceWrapper) LogoutUser

func (siw *ServerInterfaceWrapper) LogoutUser(w http.ResponseWriter, r *http.Request)

LogoutUser operation middleware

func (*ServerInterfaceWrapper) PingPong

func (siw *ServerInterfaceWrapper) PingPong(w http.ResponseWriter, r *http.Request)

PingPong operation middleware

func (*ServerInterfaceWrapper) RequestToken

func (siw *ServerInterfaceWrapper) RequestToken(w http.ResponseWriter, r *http.Request)

RequestToken operation middleware

func (*ServerInterfaceWrapper) UpdateUser

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

UpdateUser operation middleware

type UpdateUserJSONBody

type UpdateUserJSONBody UpdateUserRequest

UpdateUserJSONBody defines parameters for UpdateUser.

type UpdateUserJSONRequestBody

type UpdateUserJSONRequestBody UpdateUserJSONBody

UpdateUserJSONRequestBody defines body for UpdateUser for application/json ContentType.

type UpdateUserRequest

type UpdateUserRequest struct {
	// Embedded struct due to allOf(#/components/schemas/UserInfo)
	UserInfo `yaml:",inline"`

	// previous password
	PreviousPassword string `json:"previousPassword"`
}

UpdateUserRequest defines model for UpdateUserRequest.

func (*UpdateUserRequest) Bind

func (v *UpdateUserRequest) Bind(r *http.Request) error

type UserInfo

type UserInfo struct {

	// internal identification id
	Id *int `json:"id,omitempty"`

	// user email
	UserEmail string `json:"userEmail"`

	// user id
	UserID string `json:"userID"`

	// real world name of the user
	UserName string `json:"userName"`

	// 학번
	UserNumber int `json:"userNumber"`

	// place holder for user pw
	UserPW *string `json:"userPW,omitempty"`
}

UserInfo defines model for UserInfo.

Jump to

Keyboard shortcuts

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