// file: mirc/auto/api/routes.go

// Code generated by go-mir. DO NOT EDIT.
package routes

import (


type LoginReq struct {
	Name   string `json:"name"`
	Passwd string `json:"passwd"`

type LoginResp struct {
	JwtToken string `json:"jwt_token"`

type User interface {
	// Chain provide handlers chain for gin
	Chain() gin.HandlersChain

	Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error)
	Logout(c *gin.Context) mir.Error


type UserBinding interface {
	BindLogin(c *gin.Context) (*LoginReq, mir.Error)


type UserRender interface {
	RenderLogin(c *gin.Context, data *LoginResp, err mir.Error)
	RenderLogout(c *gin.Context, err mir.Error)


// UnimplementedUserServant can be embedded to have forward compatible implementations.
type UnimplementedUserServant struct {

// UnimplementedUserBinding can be embedded to have forward compatible implementations.
type UnimplementedUserBinding struct {
	BindAny func(*gin.Context, any) mir.Error

// UnimplementedUserRender can be embedded to have forward compatible implementations.
type UnimplementedUserRender struct {
	RenderAny func(*gin.Context, any, mir.Error)

// RegisterUserServant register User servant to gin
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
	router := e.Group("v1")
	// use chain for router
	middlewares := s.Chain()

	// register routes info to router
	router.Handle("POST", "/login/", func(c *gin.Context) {
		select {
		case <-c.Request.Context().Done():

		req, err := b.BindLogin(c)
		if err != nil {
			r.RenderLogin(c, nil, err)
		resp, err := s.Login(c, req)
		r.RenderLogin(c, resp, err)
	router.Handle("POST", "/logout/", func(c *gin.Context) {
		select {
		case <-c.Request.Context().Done():
		r.RenderLogout(c, s.Logout(c))

func (UnimplementedUserServant) Chain() gin.HandlersChain {
	return nil

func (UnimplementedUserServant) Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error) {
	return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))

func (UnimplementedUserServant) Logout(c *gin.Context) mir.Error {
	return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))

func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}

func (b UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
	obj := new(LoginReq)
	err := b.BindAny(c, obj)
	return obj, err

func (b UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}

func (r UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
	r.RenderAny(c, data, err)

func (r UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
	r.RenderAny(c, nil, err)

func (r UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}

#gomir #v300 #released #structure #tag #define #auxiliary #library #handler #routing #information #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *