-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
603 - Create API #6
Comments
open spring boot project generated from initialisr to ur preferred editors. they use intelliJ i use vscode |
ok lets first create a very simple api without the use of any database first |
create new java file called "GreetingsController.java"
package com.nellyxinwei.backend;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/greetings")
public class GreetingsController {
@GetMapping
public ResponseEntity<String> sayHello() {
return ResponseEntity.ok("Hello from our API");
}
@GetMapping("/say-good-bye")
public ResponseEntity<String> sayGoodbye() {
return ResponseEntity.ok("Goodbye and see you later");
}
} |
lets us now test our api using any http client ex: postman or vscode's thunder-client extension. you can even use ur browser just for get requests like these.
|
Timestamp: (603) 603 / 1023
The text was updated successfully, but these errors were encountered: