Documentation ¶
Index ¶
- func Setup(ctx context.Context, cfg *viper.Viper, router *gin.Engine, ...) *gin.Engine
- type AuthHandler
- type BooksHandler
- func (handler *BooksHandler) DeleteBook(ctx *gin.Context)
- func (handler *BooksHandler) GetBook(ctx *gin.Context)
- func (handler *BooksHandler) ListBooks(ctx *gin.Context)
- func (handler *BooksHandler) NewBook(ctx *gin.Context)
- func (handler *BooksHandler) SearchBooks(ctx *gin.Context)
- func (handler *BooksHandler) UpdateBook(ctx *gin.Context)
- type CookieStore
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func (*AuthHandler) SignIn ¶
func (h *AuthHandler) SignIn(ctx *gin.Context)
swagger:operation POST /signin auth signUser Signs in a user --- consumes: - application/json produces: - application/json parameters:
- name: credentials in: body name: User description: The user credentials schema: "$ref": "#/definitions/User"
responses:
'200': description: Successful operation parameters: - name: books_api_token in: cookie description: The user's session cookie/token '400': description: invalid input '401': description: unauthorised '500': description: internal server error
func (*AuthHandler) SignOut ¶
func (h *AuthHandler) SignOut(ctx *gin.Context)
swagger:operation POST /signout auth signUser Signs out a user --- responses:
'200': description: Successful operation '400': description: invalid input '401': description: unauthorised '500': description: internal server error
type BooksHandler ¶
type BooksHandler struct {
// contains filtered or unexported fields
}
BooksHandler provides a struct to wrap the api around
func NewBooksHandler ¶
func (*BooksHandler) DeleteBook ¶
func (handler *BooksHandler) DeleteBook(ctx *gin.Context)
swagger:operation DELETE /books/{id} books deleteBook Delete an existing book --- parameters:
- name: id in: path description: ID of the book required: true type: string
- name: Authorization in: header name: Authorization description: Auth header, where the JWT token should be provided type: string example: someJWTToken required: true
consumes: - application/json produces: - application/json responses:
'200': message: "Book has been deleted" '404': error: "book not found"
func (*BooksHandler) GetBook ¶
func (handler *BooksHandler) GetBook(ctx *gin.Context)
swagger:operation GET /books/{id} books getBook Returns a book --- parameters:
- name: id in: path description: ID of the book required: true type: string
consumes: - application/json produces: - application/json responses:
'200': schema: items: "$ref": "#/definitions/Book" '500': error: error description
func (*BooksHandler) ListBooks ¶
func (handler *BooksHandler) ListBooks(ctx *gin.Context)
swagger:operation GET /books books listBooks Returns list of books --- consumes: - application/json produces: - application/json responses:
'200': description: Successful operation schema: type: array items: "$ref": "#/definitions/Book" '500': description: internal server error
func (*BooksHandler) NewBook ¶
func (handler *BooksHandler) NewBook(ctx *gin.Context)
swagger:operation POST /books books addBook Adds a new book --- consumes: - application/json produces: - application/json parameters:
- name: book in: body name: Book description: The new book to create schema: "$ref": "#/definitions/Book"
- name: Authorization in: header name: Authorization description: Auth header, where the JWT token should be provided type: string example: someJWTToken required: true
responses:
'201': description: Successful operation schema: type: array items: "$ref": "#/definitions/Book" '400': description: invalid input '500': description: internal server error
func (*BooksHandler) SearchBooks ¶
func (handler *BooksHandler) SearchBooks(ctx *gin.Context)
swagger:operation GET /books/search books searchBooks Filters list of books by tag --- parameters:
- name: tag in: query description: tag to filter on required: false type: string
consumes: - application/json produces: - application/json responses:
'200': description: Successful operation schema: type: array items: "$ref": "#/definitions/Book"
func (*BooksHandler) UpdateBook ¶
func (handler *BooksHandler) UpdateBook(ctx *gin.Context)
swagger:operation PUT /books/{id} books updateBook Update an existing book --- parameters:
- name: id in: path description: ID of the book required: true type: string
consumes: - application/json produces: - application/json parameters:
- name: book in: body name: Book description: The new book to create schema: "$ref": "#/definitions/Book"
- name: Authorization in: header name: Authorization description: Auth header, where the JWT token should be provided type: string example: someJWTToken required: true
responses:
'200': description: Successful operation schema: type: array items: "$ref": "#/definitions/Book" '400': description: Invalid input '404': description: book not found '500': description: internal server error
type CookieStore ¶
type CookieStore interface {
NewCookieStore() (redisStore.Store, error)
}
type Middleware ¶
type Middleware interface { AuthJWTMiddleware(cfg *viper.Viper) gin.HandlerFunc AuthCookieMiddleware() gin.HandlerFunc }