From 064dc6c5d3ca3866bfc65934aeded4274dc6183e Mon Sep 17 00:00:00 2001 From: JMARyA Date: Mon, 16 Dec 2024 10:30:51 +0100 Subject: [PATCH] add url api --- .../programming/patterns/Programming Patterns.md | 3 +++ .../dev/programming/patterns/URL Suffix API.md | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 technology/dev/programming/patterns/URL Suffix API.md diff --git a/technology/dev/programming/patterns/Programming Patterns.md b/technology/dev/programming/patterns/Programming Patterns.md index 1099afe..de23d37 100644 --- a/technology/dev/programming/patterns/Programming Patterns.md +++ b/technology/dev/programming/patterns/Programming Patterns.md @@ -2,6 +2,9 @@ obj: meta/collection --- +# Best Practices +- [URL Suffix API](./URL%20Suffix%20API.md) + # Creational Patterns - [Abstract Factory](creational/Abstract%20Factory%20Pattern.md) - [Builder](creational/Builder%20Pattern.md) diff --git a/technology/dev/programming/patterns/URL Suffix API.md b/technology/dev/programming/patterns/URL Suffix API.md new file mode 100644 index 0000000..5214f4a --- /dev/null +++ b/technology/dev/programming/patterns/URL Suffix API.md @@ -0,0 +1,15 @@ +# URL Suffix API +When designing a website, consider leveraging URL suffixes to indicate the format of the resource being accessed, similar to how file extensions are used in operating systems. + +For example, a webpage located at `/blog/post/id` that renders human-readable content could have its machine-readable data served by appending a format-specific suffix to the same URL, such as `/blog/post/id.json`. + +#### Benefits: + +1. **Intuitive API from Website Usage** + Users can easily derive API endpoints from existing website URLs by appending the desired format suffix. + +2. **Interchangeable Formats** + The same approach allows for multiple formats (e.g., `.json`, `.msgpack`, `.protobuf`) to be supported seamlessly, improving flexibility and usability. + + +This method simplifies the architecture, enhances consistency, and provides an elegant mechanism to serve both human-readable and machine-readable content from the same base URL. \ No newline at end of file