service

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

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

Go to latest
Published: Oct 4, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TaskIDCtxKey = ctxKey("TaskIDCtxKey")

TaskIDCtxKey tên của giá trị nằm trong request context

Functions

func HeaderResponseContentTypeJSON

func HeaderResponseContentTypeJSON(next http.Handler) http.Handler

HeaderResponseContentTypeJSON chèn thông tin định dạng JSON vào tiêu đề của gói tin được gửi đi.

func TaskIDCtx

func TaskIDCtx(next http.Handler) http.Handler

TaskIDCtx lấy id của task từ đường dẫn url

Types

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware tạo một handler mới dựa trên handler được truyền vào.

func RequestLogger

func RequestLogger(logger *log.Logger) Middleware

RequestLogger in ra thông tin của yêu cầu vừa được xử lý.

type Todo

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

Todo chứa các hàm số dùng để khởi tạo và chạy dịch vụ API.

func NewTodo

func NewTodo(storage *storage.Todo) *Todo

NewTodo khởi tạo dịch vụ API.

func (*Todo) CreateOneTask

func (todo *Todo) CreateOneTask() http.HandlerFunc

CreateOneTask lấy thông tin của một tác vụ từ body của request rồi gửi cho storage.Todo để xứ lý. @Summary Create one task @Description tạo một tác vụ mới @Accept json @Produce json @Param task body service.requestCreateOneTask true "tác vụ được thêm vào" @Failure 500 {object} service.responseCreateOneTaskErr @Failure 400 {object} service.responseCreateOneTaskErr @Success 200 {object} service.responseCreateOneTask @Router /todo [post]

func (*Todo) GetHello

func (todo *Todo) GetHello() http.HandlerFunc

GetHello trả về một handler có thể xử lý yêu cầu HTTP và trả về chuỗi ký tự "Hello, world." @Summary Hello world @Description trả về chuỗi kí tự "Hello World" @Produce json @Success 200 {object} service.responseGetHello @Router /hello [get]

func (*Todo) ServeHTTP

func (todo *Todo) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dùng để gọi hàm số cung cấp bởi router nhằm thoả mãn interface http.Handler.

Jump to

Keyboard shortcuts

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