{"id":22984931,"url":"https://github.com/giuseppe998e/spring-webflux-response-wrapper","last_synced_at":"2026-05-21T05:02:34.079Z","repository":{"id":41903032,"uuid":"478998645","full_name":"giuseppe998e/spring-webflux-response-wrapper","owner":"giuseppe998e","description":"Spring WebFlux Response Wrapper (Telegram bot API style)","archived":false,"fork":false,"pushed_at":"2022-09-03T14:18:52.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T01:52:50.898Z","etag":null,"topics":["kotlin","library","response","response-wrapper","rest","spring","webflux","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giuseppe998e.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-07T13:31:28.000Z","updated_at":"2022-12-09T18:11:05.000Z","dependencies_parsed_at":"2022-08-11T20:40:49.947Z","dependency_job_id":null,"html_url":"https://github.com/giuseppe998e/spring-webflux-response-wrapper","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppe998e%2Fspring-webflux-response-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppe998e%2Fspring-webflux-response-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppe998e%2Fspring-webflux-response-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giuseppe998e%2Fspring-webflux-response-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giuseppe998e","download_url":"https://codeload.github.com/giuseppe998e/spring-webflux-response-wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246802612,"owners_count":20836369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","library","response","response-wrapper","rest","spring","webflux","wrapper"],"created_at":"2024-12-15T03:18:56.158Z","updated_at":"2026-05-21T05:02:33.966Z","avatar_url":"https://github.com/giuseppe998e.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring WebFlux Response Wrapper\nThis library allows you to wrap the content of REST responses in the format:\n```json\n{\n    \"ok\": true,\n    \"data\": \"String/Number/Object/List\"\n}\n```\n...or, in case of an error:\n```json\n{\n    \"ok\": false,\n    \"error\": {\n        \"value\": 500,\n        \"message\": \"...\"\n    }\n}\n```\n\n\u003e It will also replace not found paths with a 404 error response.\n\n## Add dependency\n### Maven\n**1.** Add the JitPack repository to your _pom.xml_ file:\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n**2.** Add dependency:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.giuseppe998e\u003c/groupId\u003e\n    \u003cartifactId\u003espring-webflux-response-wrapper\u003c/artifactId\u003e\n    \u003cversion\u003ev0.2.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n**1.** Add the JitPack repository to your _build.gradle_ file:\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n**2.** Add dependency:\n```groovy\ndependencies {\n    implementation 'com.github.giuseppe998e:spring-webflux-response-wrapper:v0.2.4'\n}\n```\n\n## Usage\n### Kotlin\n**1.** Import the configuration class:\n```kotlin\npackage com.example.spring\n\nimport brc.webflux.response.wrapper.ResponseWrapper\n//...\n\n@SpringBootApplication\n@Import(ResponseWrapper::class)\nclass ExampleMicroserviceApplication\n\nfun main(args: Array\u003cString\u003e) {\n    runApplication\u003cExampleMicroserviceApplication\u003e(*args)\n}\n```\n**2.** Create a REST controller:\n```kotlin\npackage com.example.spring\n\nimport brc.webflux.response.wrapper.model.Response\n// ...\n\n@Controller\n@RequestMapping(produces = [MediaType.APPLICATION_JSON_VALUE])\nclass ExampleRestController {\n    /*\n     * Returns:\n     * ```\n     * {\"ok\":true,\"data\":\"Example Response\"}\n     * ```\n     */\n    @GetMapping\n    fun defaultHandler(): Mono\u003cString\u003e = Mono.just(\"Example Response\")\n    \n    /*\n     * Returns:\n     * ```\n     * {\"ok\":true,\"data\":[\"Example Response #1\",\"Example Response #2\",\"Example Response #3\"]}\n     * ```\n     */\n    @GetMapping(\"/flux\")\n    fun fluxHandler(): Flux\u003cString\u003e = Flux.fromArray(\n        arrayOf(\n            \"Example Response #1\",\n            \"Example Response #2\",\n            \"Example Response #3\"\n        )\n    )\n    \n    /*\n     * Returns:\n     * ```\n     * {\"ok\":false,\"error\":{\"value\":500,\"message\":\"Internal Server Error\"}}\n     * ```\n     */\n    @GetMapping(\"/error\")\n    fun errorHandler(): Mono\u003cString\u003e =\n        Mono.error(Exception(\"This error will be logged but not returned (Code: 500 - INTERNAL SERVER ERROR)\"))\n    \n    /*\n     * Returns:\n     * ```\n     * {\"ok\":false,\"error\":{\"value\":400,\"message\":\"This error will NOT be logged, but returned\"}}\n     * ```\n     */\n    @GetMapping(\"/error/custom\")\n    fun customErrorHandler(): Mono\u003cString\u003e =\n        Mono.error(Response.Error(HttpStatus.BAD_REQUEST, \"This error wont be logged but returned\"))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiuseppe998e%2Fspring-webflux-response-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiuseppe998e%2Fspring-webflux-response-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiuseppe998e%2Fspring-webflux-response-wrapper/lists"}