server

package
v0.0.0-...-c4cacf9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package server provides primitives to interact with the openapi HTTP API.

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

Package server provides primitives to interact with the openapi HTTP API.

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

Package server provides primitives to interact with the openapi HTTP API.

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

Index

Constants

View Source
const (
	Petstore_authScopes = "petstore_auth.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func New

func New(config *config.Configuration, httpHandler ServerInterface) *http.Server

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router *gin.Engine, si ServerInterface) *gin.Engine

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router *gin.Engine, si ServerInterface, options GinServerOptions) *gin.Engine

RegisterHandlersWithOptions creates http.Handler with additional options

Types

type AddCommentJSONBody

type AddCommentJSONBody CommentRequest

AddCommentJSONBody defines parameters for AddComment.

type AddCommentJSONRequestBody

type AddCommentJSONRequestBody AddCommentJSONBody

AddCommentJSONRequestBody defines body for AddComment for application/json ContentType.

type AddReactJSONBody

type AddReactJSONBody ReactRequest

AddReactJSONBody defines parameters for AddReact.

type AddReactJSONRequestBody

type AddReactJSONRequestBody AddReactJSONBody

AddReactJSONRequestBody defines body for AddReact for application/json ContentType.

type CommentId

type CommentId int

CommentId defines model for commentId.

type CommentRequest

type CommentRequest struct {
	Content      string `json:"content"`
	ParentId     *int   `json:"parent_id,omitempty"`
	ParentPostId int    `json:"parent_post_id"`
}

CommentRequest defines model for CommentRequest.

type CommentResponse

type CommentResponse struct {
	AuthorId       *int64  `json:"author_id,omitempty"`
	AuthorUsername *string `json:"author_username,omitempty"`
	Content        *string `json:"content,omitempty"`
	Id             *int64  `json:"id,omitempty"`

	// describe whether a post is already reacted by user, if tru
	IsReacted  *bool         `json:"is_reacted,omitempty"`
	ReactViews *[]ReactCount `json:"react_views,omitempty"`

	// replies of this comment
	Replies *[]CommentResponse `json:"replies,omitempty"`
}

CommentResponse defines model for CommentResponse.

type CreatePostJSONBody

type CreatePostJSONBody PostRequest

CreatePostJSONBody defines parameters for CreatePost.

type CreatePostJSONRequestBody

type CreatePostJSONRequestBody CreatePostJSONBody

CreatePostJSONRequestBody defines body for CreatePost for application/json ContentType.

type CreateUserJSONBody

type CreateUserJSONBody User

CreateUserJSONBody defines parameters for CreateUser.

type CreateUserJSONRequestBody

type CreateUserJSONRequestBody CreateUserJSONBody

CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
	Status  bool   `json:"status"`
}

describe error

type GinServerOptions

type GinServerOptions struct {
	BaseURL     string
	Middlewares []MiddlewareFunc
}

GinServerOptions provides options for the Gin server.

type LoginUserParams

type LoginUserParams struct {
	// The user name for login
	Username *string `json:"username,omitempty"`

	// The password for login in clear text
	Password *string `json:"password,omitempty"`
}

LoginUserParams defines parameters for LoginUser.

type MiddlewareFunc

type MiddlewareFunc func(c *gin.Context)

type OAuth2ConfigInterface

type OAuth2ConfigInterface interface {
	AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	Client(ctx context.Context, t *oauth2.Token) *http.Client
}

type OauthHandler

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

func NewOauthHandler

func NewOauthHandler(
	configInterface OAuth2ConfigInterface,
	githubService blogo.GitHubInterface,
) OauthHandler

func (OauthHandler) Authorize

func (h OauthHandler) Authorize(ctx *gin.Context)

func (OauthHandler) GithubCallbackHandler

func (h OauthHandler) GithubCallbackHandler(ctx *gin.Context)

type PostId

type PostId int64

PostId defines model for postId.

type PostRequest

type PostRequest struct {
	Content string `json:"content"`
	Title   string `json:"title"`
}

PostRequest defines model for PostRequest.

type PostResponse

type PostResponse struct {
	AuthorId       *int64  `json:"author_id,omitempty"`
	AuthorUsername *string `json:"author_username,omitempty"`
	Content        *string `json:"content,omitempty"`
	Id             *int64  `json:"id,omitempty"`

	// describe whether a post is already reacted by user
	IsReacted  *bool         `json:"is_reacted,omitempty"`
	Name       *string       `json:"name,omitempty"`
	ReactViews *[]ReactCount `json:"react_views,omitempty"`

	// replies of the post
	Replies *[]CommentResponse `json:"replies,omitempty"`
}

PostResponse defines model for PostResponse.

type PostsResponse

type PostsResponse []PostResponse

Response for multiple post

type ReactCount

type ReactCount struct {
	Count   *int `json:"count,omitempty"`
	ReactId *int `json:"react_id,omitempty"`
}

describe count of reaction on a given resource (eg: post, comment)

type ReactListResponse

type ReactListResponse []struct {
	Id   *int64  `json:"id,omitempty"`
	Name *string `json:"name,omitempty"`

	// url of the react thumbnail
	ThumbnailImg *string `json:"thumbnail_img,omitempty"`
}

ReactListResponse defines model for ReactListResponse.

type ReactRequest

type ReactRequest struct {
	CommentId *int64 `json:"comment_id,omitempty"`
	PostId    *int64 `json:"post_id,omitempty"`

	// id of the react type. Get the id from react list endpoint
	ReactId int64 `json:"react_id"`
}

ReactRequest defines model for ReactRequest.

type ResourceCreatedResponse

type ResourceCreatedResponse struct {
	Message string `json:"message"`
	Status  bool   `json:"status"`
}

ResourceCreatedResponse defines model for ResourceCreatedResponse.

type ServerInterface

type ServerInterface interface {

	// (POST /api/v1/comment)
	AddComment(c *gin.Context)

	// (GET /api/v1/comment/{commentId})
	GetCommentByID(c *gin.Context, commentId CommentId)
	// get multiple post
	// (GET /api/v1/post)
	GetPost(c *gin.Context)
	// Create a new post
	// (POST /api/v1/post)
	CreatePost(c *gin.Context)
	// Finds Post by ID
	// (GET /api/v1/post/{postId})
	FindPostByID(c *gin.Context, postId PostId)

	// (GET /api/v1/react/)
	GetReactList(c *gin.Context)

	// (POST /api/v1/react/)
	AddReact(c *gin.Context)
	// Create user
	// (POST /user)
	CreateUser(c *gin.Context)
	// Logs user into the system
	// (GET /user/login)
	LoginUser(c *gin.Context, params LoginUserParams)
	// Logs out current logged in user session
	// (GET /user/logout)
	LogoutUser(c *gin.Context)
	// Delete user
	// (DELETE /user/{username})
	DeleteUser(c *gin.Context, username string)
	// Get user by user name
	// (GET /user/{username})
	GetUserByName(c *gin.Context, username string)
	// Update user
	// (PUT /user/{username})
	UpdateUser(c *gin.Context, username string)
}

ServerInterface represents all server handlers.

func NewHandler

func NewHandler(
	config *config.Configuration,
	postService *blogo.PostService,
	commentService *blogo.CommentService,
	reactService *blogo.ReactService,

) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) AddComment

func (siw *ServerInterfaceWrapper) AddComment(c *gin.Context)

AddComment operation middleware

func (*ServerInterfaceWrapper) AddReact

func (siw *ServerInterfaceWrapper) AddReact(c *gin.Context)

AddReact operation middleware

func (*ServerInterfaceWrapper) CreatePost

func (siw *ServerInterfaceWrapper) CreatePost(c *gin.Context)

CreatePost operation middleware

func (*ServerInterfaceWrapper) CreateUser

func (siw *ServerInterfaceWrapper) CreateUser(c *gin.Context)

CreateUser operation middleware

func (*ServerInterfaceWrapper) DeleteUser

func (siw *ServerInterfaceWrapper) DeleteUser(c *gin.Context)

DeleteUser operation middleware

func (*ServerInterfaceWrapper) FindPostByID

func (siw *ServerInterfaceWrapper) FindPostByID(c *gin.Context)

FindPostByID operation middleware

func (*ServerInterfaceWrapper) GetCommentByID

func (siw *ServerInterfaceWrapper) GetCommentByID(c *gin.Context)

GetCommentByID operation middleware

func (*ServerInterfaceWrapper) GetPost

func (siw *ServerInterfaceWrapper) GetPost(c *gin.Context)

GetPost operation middleware

func (*ServerInterfaceWrapper) GetReactList

func (siw *ServerInterfaceWrapper) GetReactList(c *gin.Context)

GetReactList operation middleware

func (*ServerInterfaceWrapper) GetUserByName

func (siw *ServerInterfaceWrapper) GetUserByName(c *gin.Context)

GetUserByName operation middleware

func (*ServerInterfaceWrapper) LoginUser

func (siw *ServerInterfaceWrapper) LoginUser(c *gin.Context)

LoginUser operation middleware

func (*ServerInterfaceWrapper) LogoutUser

func (siw *ServerInterfaceWrapper) LogoutUser(c *gin.Context)

LogoutUser operation middleware

func (*ServerInterfaceWrapper) UpdateUser

func (siw *ServerInterfaceWrapper) UpdateUser(c *gin.Context)

UpdateUser operation middleware

type UpdateUserJSONBody

type UpdateUserJSONBody User

UpdateUserJSONBody defines parameters for UpdateUser.

type UpdateUserJSONRequestBody

type UpdateUserJSONRequestBody UpdateUserJSONBody

UpdateUserJSONRequestBody defines body for UpdateUser for application/json ContentType.

type User

type User struct {
	Email     *string `json:"email,omitempty"`
	FirstName *string `json:"firstName,omitempty"`
	Id        *int64  `json:"id,omitempty"`
	LastName  *string `json:"lastName,omitempty"`
	Password  *string `json:"password,omitempty"`
	Phone     *string `json:"phone,omitempty"`

	// User Status
	UserStatus *int32  `json:"userStatus,omitempty"`
	Username   *string `json:"username,omitempty"`
}

User defines model for User.

Jump to

Keyboard shortcuts

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