Skip to content

快速构建Web应用,整合Knife4j接口文档,自定义错误码和全局异常处理器,一切尽在EasyWeb。

License

Notifications You must be signed in to change notification settings

qimu666/EasyWeb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 简体中文

EasyWeb

Quickly build web applications, integrate Knife4j interface documentation, customize error codes and global exception handlers, all in EasyWeb.

Quick Start 🏁

To get started with EasyWeb, you can follow these simple steps:

  1. Create a SpringBoot project without adding Web dependencies.

  2. Add the dependency coordinates:

    <dependency>
       <groupId>icu.qimuu</groupId>
       <artifactId>EasyWeb</artifactId>
       <version>0.0.6</version>
    </dependency>
  3. Configuration information:

    • 💥 Starting from 0.0.6 in the new version, you can use the Knife4j interface documentation, custom error codes, and global exception handlers without any configuration, and you will not feel the presence of EasyWeb

    • Of course, you can also configure some personalized configurations that you need. The configurations are as follows:

       knife4j:
         config:
           name: Author
           email: xxx
           version: API version
           title: API document
           description: API document description
           scan-path: com.qimuu.demo.controller
       spring:
         profiles:
           active: dev
         mvc:
           path match:
             matching-strategy: ant_path_matcher

    When using, annotations such as @RestController or @Controller need to be added to the control layer class

  4. Sample code

    @GetMapping("/getPoisonousChickenSoupNotSetKey")
    public BaseResponse<PoisonousChickenSoupResponse> getPoisonousChickenSoupNotSetKey() {
        PoisonousChickenSoupResponse poisonousChickenSoup = null;
        try {
            poisonousChickenSoup = apiService.getPoisonousChickenSoup();
        } catch (BusinessException e) {
            throw new BusinessException(e.getCode(), e.getMessage());
        }
        return ResultUtils.success(poisonousChickenSoup);
    }
  5. Response Example:

    {
      "code": 0,
      "data": {
        "text": "The three major human illusions a phone rings, someone knocks at the door, and they like me."
      },
      "message": "ok"
    }

If you do not want to use the Knife4j interface documentation, simply configure as follows to close the knife4j interface

   knife4j:
     enable: true
     production: true

If you want the interface document to enable authentication, just configure the following

knife4j:
  # Enable enhanced configuration
  enable: true
  basic:
    enable: true
    # Set your own Basic authentication user name
    username: root
    # Set your own Basic authentication password
    password: 1234

Custom Error Codes 👌

  • By implementing the Error interface, you can define your own team’s error handling specifications!

    Example:

      public enum ErrorCode implements Error {   
          /**
           * Status code
           */
          private final int code;
      
          /**
           * error message
           */
          private final String message;
          
          /**
           * success
           */
          SUCCESS(0, "ok"),
          
          /**
           * Request parameter error
           */
          PARAMS_ERROR(40000, "请求参数错误");
          
          @Override
          public int getCode() {
              return code;
          }
          
          @Override
          public String getMessage() {
              return message;
          }
      }

Our Advantages 😎

Compared with the traditional way of creating web projects, there is no need to integrate interface documents, and it has rich error codes and flexible global exception handlers.

  • Traditional way of creating web projects:

    1. Create a new project.

    2. Write a global exception handler.

    3. Integrate the interface document.

    4. Customize error codes.

    5. Customize the common return class.

    6. Write business code.

  • Use EasyWeb:

    1. Create a new project.
    2. Add EasyWeb coordinates.
    3. Configure scanning paths and scanning policies.
    4. Write business code.

Features 🌟

EasyWeb provides a variety of features to make your web development process easier and more efficient. Some key features include:

  • Quick and easy web application construction.
  • Simple and intuitive API.
  • Flexibility to customize your web application.
  • And more!

Contribution 🤝

If you have any questions or suggestions about EasyWeb, please feel free to contact us at any time: 📩 Email: [email protected] .

Contact Us 📩

If you have any questions or suggestions about EasyWeb, please feel free to contact us.

Thank you for using EasyWeb! 😊

About

快速构建Web应用,整合Knife4j接口文档,自定义错误码和全局异常处理器,一切尽在EasyWeb。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages