Giter VIP home page Giter VIP logo

httpresponse's Introduction

HttpResponse

常用的HTTP返回,可复用

封装了常用的200OK、403Forbidden、404NotFound等常用Http响应格式

使用方法:

在Gradle或maven中引入:

Gradle:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

dependencies {
	     implementation 'com.github.farewell12345:HttpResponse:2.0.2'
}

Maven:

<repositories>
	<repository>
		  <id>jitpack.io</id>
		  <url>https://jitpack.io</url>
	</repository>
</repositories>

<dependency>
	   <groupId>com.github.farewell12345</groupId>
	   <artifactId>HttpResponse</artifactId>
	   <version>2.0.2</version>
</dependency>

使用示例:

@GetMapping("/hello")
public Response<String> hello(){
    return ResponseFactoryImpl.build().success("Ok","hello!");
}

返回示例:

{
    "success": true,
    "code": 200,
    "data": "hello!",
    "message": "Ok"
}

目前支持的状态码:

状态码 变量名
200 SUCCESS
201 CREATED
202 ACCEPTED
204 NO_CONTENT
203 NON_AUTHORITATIVE
205 RESET_CONTENT
206 PARTIAL_CONTENT
300 MULTIPLE_CHOICES
301 MOVED_PERMANENTLY
302 REDIRECT
303 SEE_OTHER
304 NOT_MODIFIED
305 USE_PROXY
400 BAD_REQUEST
401 UNAUTHORIZED
403 FORBIDDEN
404 NOT_FOUND
405 METHOD_NOT_ALLOWED
500 INTERNAL_SERVER_ERROR
501 NOT_IMPLEMENTED
502 BAD_GATEWAY
504 GATEWAY_TIMEOUT
505 HTTP_VERSION_NOT_SUPPORTED

httpresponse's People

Contributors

dev-umb avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.