Skip to content
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

Closed
Tracked by #1
njtalba5127 opened this issue Dec 8, 2022 · 4 comments · Fixed by #24 or #27
Closed
Tracked by #1

603 - Create API #6

njtalba5127 opened this issue Dec 8, 2022 · 4 comments · Fixed by #24 or #27
Assignees
Labels
enhancement New feature or request

Comments

@njtalba5127
Copy link
Member

njtalba5127 commented Dec 8, 2022

Timestamp: (603) 603 / 1023

@njtalba5127 njtalba5127 mentioned this issue Dec 8, 2022
23 tasks
@njtalba5127 njtalba5127 added the enhancement New feature or request label Dec 8, 2022
@njtalba5127 njtalba5127 self-assigned this Dec 8, 2022
@njtalba5127
Copy link
Member Author

open spring boot project generated from initialisr to ur preferred editors.

they use intelliJ

i use vscode

@njtalba5127
Copy link
Member Author

ok lets first create a very simple api without the use of any database first

@njtalba5127
Copy link
Member Author

njtalba5127 commented Dec 16, 2022

create new java file called "GreetingsController.java"

.
.
└── backend
    ├── HELP.md
    ├── mvnw
    ├── mvnw.cmd
    ├── pom.xml
    ├── src
    │   ├── main
    │   │   ├── java
    │   │   │   └── com
    │   │   │       └── nellyxinwei
    │   │   │           └── backend
    │   │   │               ├── BackendApplication.java
    │   │   │               └── 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");
  }

}

@njtalba5127
Copy link
Member Author

njtalba5127 commented Dec 16, 2022

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.

thunder-client:

GET
http://localhost:8080/api/v1/greetings

output:

Hello from our API

thunder-client:

GET
http://localhost:8080/api/v1/greetings/say-good-bye

output:

Goodbye and see you later

This was linked to pull requests Dec 16, 2022
Repository owner moved this from In Progress to Done in 2223-1202WinterFuyu-Projects Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant