-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblogs.json
1 lines (1 loc) · 5.28 KB
/
blogs.json
1
[{"id":"fd4893c2-92f0-42a5-8109-10fc9223eb13","title":"SServer Guide","content":"\u003cp\u003eThis server is based on \u003ca title\u003d\"Spring Boot\" href\u003d\"https://spring.io/projects/spring-boot\" target\u003d\"_blank\" rel\u003d\"noopener\"\u003eSpring Boot\u003c/a\u003e which allows users to create easy stand-alone, production-grade Spring based Applications.\u003c/p\u003e\n\u003cp\u003eThis server is using the following methods depending on which endpoint you are sending your request.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ccode\u003eGET\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ePOST\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eDELETE\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eAll of the features that is explained below are also implemented in the front-end of the server where you can see, create and delete posts.\u003c/p\u003e\n\u003ch3\u003eMain Endpoint\u003c/h3\u003e\n\u003cp\u003eThe main endpoint of this server is\u0026nbsp;\u003ccode\u003ehttp://localhost:8080/\u003c/code\u003e\u0026nbsp;or\u0026nbsp;\u003ccode\u003ehttp://localhost:8080/index.html\u003c/code\u003e. When a client sends a\u0026nbsp;\u003ccode\u003eGET\u003c/code\u003e\u0026nbsp;request to these endpoint the response will be the html code of the main page which can be opened in the browser.\u003c/p\u003e\n\u003cp\u003eBut if client sends a\u0026nbsp;\u003ccode\u003ePOST\u003c/code\u003e\u0026nbsp;or any other\u0026nbsp;\u003cem\u003ehttp method\u003c/em\u003e to this endpoint the server will return a\u0026nbsp;\u003ccode\u003e405 Method Not Allowed\u003c/code\u003e\u0026nbsp;response in json format.\u003c/p\u003e\n\u003cpre style\u003d\"font-size: 12px;\"\u003e{\u003cbr /\u003e \"timestamp\": \"2021-12-20T00:01:39.625+00:00\",\u003cbr /\u003e \"status\": 405,\u003cbr /\u003e \"error\": \"Method Not Allowed\",\u003cbr /\u003e \"trace\": \"org.springframework.web.HttpRequestMethodNotSupportedException: Request method \u0027POST\u0027 not supported....\",\u003cbr /\u003e \"message\": \"Request method \u0027POST\u0027 not supported\",\u003cbr /\u003e \"path\": \"/\"\u003cbr /\u003e}\u003c/pre\u003e\n\u003ch2\u003eBlog Endpoint\u003c/h2\u003e\n\u003cp style\u003d\"font-size: 12px;\"\u003e\u003cspan style\u003d\"font-size: medium;\"\u003eThe \u003cem\u003eblog\u003c/em\u003e endpoint of this server is at\u0026nbsp;\u003ccode\u003ehttp://localhost:8080/blog\u003c/code\u003e\u0026nbsp;and this endpoint supports the \u003ccode\u003eGET\u003c/code\u003e, \u003ccode\u003ePOST\u003c/code\u003e and \u003ccode\u003eDELETE\u003c/code\u003e methods. The example and exaplanation of each method is described below.\u003c/span\u003e\u003c/p\u003e\n\u003cp style\u003d\"font-size: 12px;\"\u003e\u0026nbsp;\u003c/p\u003e\n\u003ch3\u003eGET Method\u003c/h3\u003e\n\u003cp\u003eThis method will return a json response will all blog posts available.\u003c/p\u003e\n\u003cpre\u003ecurl -XGET \u0027http://localhost:8080\u0027\u003c/pre\u003e\n\u003cp\u003eThe response of will be an array of blog posts:\u003c/p\u003e\n\u003cpre\u003e[\u003cbr /\u003e {\u003cbr /\u003e \"id\": \"bf94aca0-14a6-4e21-b9ac-bcaabb38224b\",\u003cbr /\u003e \"title\": \"Code block\",\u003cbr /\u003e \"content\": \"\u0026lt;p\u0026gt;This aspncfsiadnmad\u0026amp;nbsp;\u0026lt;/p\u0026gt;\n\u0026lt;p\u0026gt;asdkas pdas mdkaspkdpsad,sapd,as\u0026lt;/p\u0026gt;\n\u0026lt;pre\u0026gt;curl \u0026lt;a href\u003d\\\"https://localhost:8080\\\"\u0026gt;https://localhost:8080\u0026lt;/a\u0026gt; -method:POST \u0026lt;/pre\u0026gt;\"\u003cbr /\u003e \"date\": \"2021-12-20\"\u003cbr /\u003e }\u003cbr /\u003e]\u003cbr /\u003e\u003cbr /\u003e\u003c/pre\u003e\n\u003ch3\u003ePOST Method\u003c/h3\u003e\n\u003cp\u003eThis method will make a new blog post in the database. The body of the \u003ccode\u003ePOST\u003c/code\u003e\u0026nbsp;method should be defined in a json format with the following structure:\u003c/p\u003e\n\u003cpre\u003e{\u003cbr /\u003e \"title\": \"Title of the blog\",\u003cbr /\u003e \"content\": \"Content of the blog which accepts html elements.\"\u003cbr /\u003e}\u003c/pre\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003ecurl -XPOST -d \u0027{\n \"title\": \"Blog 1231\",\n \"content\": \"THIS IS THE CONTENT\"\n}\u0027 \u0027http://localhost:8080/blog\u0027\u003c/pre\u003e\n\u003cp\u003eIf the results where successfull the server will return nothing. In addition, if there is a blog with the exact title, the server will return an \u003ccode\u003e500 Internal Server\u003c/code\u003e error to prevent posts with exact title.\u003c/p\u003e\n\u003ch3\u003eDELETE Method\u003c/h3\u003e\n\u003cp\u003eThis method is used to delete a blog post. The endpoint for this method is defined as:\u0026nbsp;\u003ccode\u003ehttp://localhost:8080/blog/id\u003c/code\u003e where,\u0026nbsp;\u003ccode\u003eid\u003c/code\u003e\u0026nbsp;is refering to the blog\u0027s id which can be found in the blog endpoint.\u003cem\u003e\u0026nbsp;\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003ecurl -XDELETE \u0027http://localhost:8080/blog/d378be8c-8d41-4769-afac-342b2d7c1a92\u0027\u003c/pre\u003e\n\u003cp\u003eIf the delete operation was successful the server will return nothing otherwise it will return an error.\u0026nbsp;\u003c/p\u003e\n","date":"2022-02-04"}]