mirror of
https://github.com/go-kratos/kratos.git
synced 2026-05-16 09:48:28 +02:00
b9f821c29f
* add http handler * fix request error
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
// Code generated by protoc-gen-go-http. DO NOT EDIT.
|
|
|
|
package v1
|
|
|
|
import (
|
|
context "context"
|
|
http1 "github.com/go-kratos/kratos/v2/transport/http"
|
|
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
|
|
mux "github.com/gorilla/mux"
|
|
http "net/http"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the kratos package it is being compiled against.
|
|
var _ = new(http.Request)
|
|
var _ = new(context.Context)
|
|
var _ = binding.MapProto
|
|
var _ = mux.NewRouter
|
|
|
|
const _ = http1.SupportPackageIsVersion1
|
|
|
|
type BlogServiceHandler interface {
|
|
CreateArticle(context.Context, *CreateArticleRequest) (*CreateArticleReply, error)
|
|
|
|
DeleteArticle(context.Context, *DeleteArticleRequest) (*DeleteArticleReply, error)
|
|
|
|
GetArticle(context.Context, *GetArticleRequest) (*GetArticleReply, error)
|
|
|
|
ListArticle(context.Context, *ListArticleRequest) (*ListArticleReply, error)
|
|
|
|
UpdateArticle(context.Context, *UpdateArticleRequest) (*UpdateArticleReply, error)
|
|
}
|
|
|
|
func NewBlogServiceHandler(srv BlogServiceHandler, opts ...http1.HandleOption) http.Handler {
|
|
r := mux.NewRouter()
|
|
|
|
r.Handle("/v1/article/", http1.NewHandler(srv.CreateArticle, opts...)).Methods("POST")
|
|
|
|
r.Handle("/v1/article/{id}", http1.NewHandler(srv.UpdateArticle, opts...)).Methods("PUT")
|
|
|
|
r.Handle("/v1/article/{id}", http1.NewHandler(srv.DeleteArticle, opts...)).Methods("DELETE")
|
|
|
|
r.Handle("/v1/article/{id}", http1.NewHandler(srv.GetArticle, opts...)).Methods("GET")
|
|
|
|
r.Handle("/v1/article/", http1.NewHandler(srv.ListArticle, opts...)).Methods("GET")
|
|
|
|
return r
|
|
}
|