8000 GitHub - leisurelyrcxf/gengin: generic gin
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

leisurelyrcxf/gengin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A web framework using generic and gin.

Gengin allows you to focus on your business logic. No need to write any code regard to http handler or router any more.

Gengin can also generate restful inteface descriptions automatically.

You can use just a few lines code to create a web application, sth like below:

    type Service interface {
        Auth(ctx context.Context, token string) (*types.Session, error)
    
        SignIn(ctx context.Context, req types.SigninRequest) (types.SigninResponse, error)
        Profile(ctx context.Context, req types.ProfileRequest, session *types.Session) (types.ProfileResponse, error)
    }
    
    ...
    
    var srv Service = your_service_impl
    
    v1 := s.Group("v1")
    services := gengin.NewServices("usr", v1, "User", srv.Auth, nil)
	
    gengin.RegisterService(services, "SignIn", "", "POST", "login", srv.SignIn)
    gengin.RegisterAuthenticatedService(services, "Profile", "", "GET", "get user profile", srv.Profile)
    
    ...
    
    fmt.Println(servies.GetDescription()) // Generate restful interfaces used to align with front end
    

Refer to example to find more detail.

About

generic gin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0