http

package
v0.0.0-...-be96ee6 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONMiddleware

func JSONMiddleware(next http.Handler) http.Handler

func JWTAuth

func JWTAuth(
	original func(w http.ResponseWriter, r *http.Request),
) func(w http.ResponseWriter, r *http.Request)

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

func TimeoutMiddleware

func TimeoutMiddleware(next http.Handler) http.Handler

Types

type CommentService

type CommentService interface {
	PostComment(context.Context, comment.Comment) (comment.Comment, error)
	GetComment(ctx context.Context, ID string) (comment.Comment, error)
	UpdateComment(ctx context.Context, ID string, newCmt comment.Comment) (comment.Comment, error)
	DeleteComment(ctx context.Context, ID string) error
}

type Handler

type Handler struct {
	Router  *mux.Router
	Service CommentService
	Server  *http.Server
}

func NewHandler

func NewHandler(service CommentService) *Handler

func (*Handler) DeleteComment

func (h *Handler) DeleteComment(w http.ResponseWriter, r *http.Request)

func (*Handler) GetComment

func (h *Handler) GetComment(w http.ResponseWriter, r *http.Request)

func (*Handler) PostComment

func (h *Handler) PostComment(w http.ResponseWriter, r *http.Request)

func (*Handler) Serve

func (h *Handler) Serve() error

func (*Handler) UpdateComment

func (h *Handler) UpdateComment(w http.ResponseWriter, r *http.Request)

type PostCommentRequest

type PostCommentRequest struct {
	Slug   string `json:"slug" validate:"required"`
	Author string `json:"author" validate:"required"`
	Body   string `json:"body" validate:"required"`
}

type Response

type Response struct {
	Message string
}

Jump to

Keyboard shortcuts

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