Skip to content

Commit

Permalink
Implemented PATCH method
Browse files Browse the repository at this point in the history
  • Loading branch information
ismagilov committed Apr 19, 2017
1 parent 6b35223 commit 68cd2cc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<packaging>jar</packaging>
<url>https://mangoo.io</url>
<properties>
<mangooio.version>4.3.2</mangooio.version>
<mangooio.version>4.4.0-SNAPSHOT</mangooio.version>
<jooq.version>3.9.1</jooq.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<db.url>jdbc:h2:mem:todobackend;INIT=runscript from 'src/main/resources/db/init.sql';</db.url>
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/controllers/ApplicationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,4 @@ public Response options() {
private String appendIdToUrl(Request r, long id) {
return (r.getURL().endsWith("/")) ? r.getURL() + id : r.getURL() + "/" + id;
}

//POST: {"title":"a todo"}
//{"title":"a todo","completed":false,"url":"http://todobackend-spring.herokuapp.com//28","order":null}

//DELETE: / - deletes all todos
//

//GET: / - returns all as an array
//[{"id":1,"title":"walk the dog","completed":false,"order":0,"url":"https://todo-backend-spring4-java8.herokuapp.com/todos/1"}]

// Request URL:http://todobackend-mangooio.herokuapp.com/5
// Request Method:OPTIONS
// Status Code:404 Not Found

//GET: http://todobackend-spring.herokuapp.com//4
//{"title":"my todo","completed":false,"url":"http://todobackend-spring.herokuapp.com//4","order":null}

// Request URL:http://todobackend-spring.herokuapp.com//7
// Request Method:PATCH
//
// {completed: true}
// {title: "bathe the cat"}
// {title: "changed title", completed: true}
// {order: 95}
}
2 changes: 1 addition & 1 deletion src/main/java/filters/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class CorsFilter implements MangooRequestFilter {
public Response execute(Request request, Response response) {
response.andHeader(HttpString.tryFromString("Access-Control-Allow-Origin"), "*");
response.andHeader(HttpString.tryFromString("Access-Control-Allow-Methods"), "GET, POST, DELETE, OPTIONS");
response.andHeader(HttpString.tryFromString("Access-Control-Allow-Methods"), "GET, POST, DELETE, PATCH, OPTIONS");

if (Methods.OPTIONS.equals(request.getMethod())) {
response.andHeader(HttpString.tryFromString("Access-Control-Allow-Headers"),
Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ test:
port : 3025

dev:
application:
secret: cryptex[ak/sBnenQrAuSEd7xjWaRvZKrhorEViuN9+u2715aRAF0VNgVaMp6JH89+1UpN8gIosdo6bG7s430v+NLU1aKOkrcJeaKDIic7AM2cuLiJE=]
#cryptex[ak/sBnenQrAuSEd7xjWaRvZKrhorEViuN9+u2715aRAF0VNgVaMp6JH89+1UpN8gIosdo6bG7s430v+NLU1aKOkrcJeaKDIic7AM2cuLiJE=]
#1234567890123456789012345678901234567890123456789012345678901234567890
masterkey: /Users/ilya/Work/Projects/todobackend-mangooio/master.txt
admin:
enable: true
username: cryptex[XnrslCZdmq9BW27skRxH5g==]
# ilya
# cryptex[XnrslCZdmq9BW27skRxH5g==]
password: $2a$12$dLSHOqKzDEt6tictTGbn8epV0kTEbiWpHx/VVRDoUVpFiS2bu6I6y
#12345
connector:
http:
host : localhost
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ routes:
url: /{id}
mapping: ApplicationController.delete

- method: POST
- method: PATCH
url: /{id}
mapping: ApplicationController.modify

0 comments on commit 68cd2cc

Please sign in to comment.