[GH-ISSUE #640] [meta] New API & logic domains #323

Closed
opened 2026-02-25 23:33:57 +03:00 by kerem · 4 comments
Owner

Originally created by @fmartingr on GitHub (Jul 9, 2023).
Original GitHub issue: https://github.com/go-shiori/shiori/issues/640

Originally assigned to: @fmartingr on GitHub.

Summary

This is the meta-task for the ongoing of refactoring the API into the Gin framework, that will split the logic into different files to ease maintenance this way:

http/
├── context/
│   └── ... # Contains custom context types for the handlers.
├── frontend/
│   └── ... # Contains the assets for the frontend.
├── middleware/
│   ├── auth.go # Contains the middleware for the authentication.
│   └── ... # Other middlewares
├── response/
│   └── ... # Contains the response types for the API.
├── routes/
│   ├── api/
│   │   ├── v1/
│   │   │   ├── bookmark.go # Contains the API routes for the bookmark endpoints.
│   │   │   └── ...
│   ├── bookmark.go # Contains the routes for the UI bookmark endpoints.
│   └── ... # Other UI endpoints
└── server.go # The main file of the server, contains the main function and the server struct.

While this issue is open/currently being worked on, the two APIs will coexist in the code, though only the legacy one will be exposed to end users until the refactored one is complete.

Migration status

UI Routes

Category Method Endpoint Ready Tested Migrated
System GET /system/liveness
Bookmarks GET /bookmarks/:id/content
Bookmarks GET /bookmarks/:id/archive
Bookmarks GET /bookmarks/:id/thumb
Bookmarklet GET /bookmarklet
UI GET /*files*

API routes

Category Method Endpoint Ready Swagger Tested Migrated
Tags GET /api/v1/tags
Tags POST /api/v1/tags
Tags PUT/PATCH /api/v1/tags/:id
Tags DELETE /api/v1/tags/:id
Accounts GET /api/v1/accounts
Accounts POST /api/v1/accounts
Accounts PUT/PATCH /api/v1/accounts/:id
Accounts DELETE /api/v1/accounts/:id
Auth GET /api/v1/auth/account
Auth PUT /api/v1/auth/account
Auth POST /api/v1/auth/login
Auth POST /api/v1/auth/refresh
Bookmarks GET /api/v1/bookmarks
Bookmarks POST /api/v1/bookmarks
Bookmarks PUT /api/v1/bookmarks/cache
Bookmarks GET /api/v1/bookmarks/:id
Bookmarks PUT/PATCH /api/v1/bookmarks/:id
Bookmarks PUT /api/v1/bookmarks/:id/cache

Database

Category SQLite MySQL PSQL
CreateTags

Logic domains

  • Auth
Originally created by @fmartingr on GitHub (Jul 9, 2023). Original GitHub issue: https://github.com/go-shiori/shiori/issues/640 Originally assigned to: @fmartingr on GitHub. ## Summary This is the meta-task for the ongoing of refactoring the API into the Gin framework, that will split the logic into different files to ease maintenance this way: ```bash http/ ├── context/ │ └── ... # Contains custom context types for the handlers. ├── frontend/ │ └── ... # Contains the assets for the frontend. ├── middleware/ │ ├── auth.go # Contains the middleware for the authentication. │ └── ... # Other middlewares ├── response/ │ └── ... # Contains the response types for the API. ├── routes/ │ ├── api/ │ │ ├── v1/ │ │ │ ├── bookmark.go # Contains the API routes for the bookmark endpoints. │ │ │ └── ... │ ├── bookmark.go # Contains the routes for the UI bookmark endpoints. │ └── ... # Other UI endpoints └── server.go # The main file of the server, contains the main function and the server struct. ``` While this issue is open/currently being worked on, the two APIs will coexist in the code, though only the legacy one will be exposed to end users until the refactored one is complete. ## Related pull requests - Base work, new API using Gin, Auth domain, QoL: https://github.com/go-shiori/shiori/pull/497 - https://github.com/go-shiori/shiori/pull/648 - https://github.com/go-shiori/shiori-web-ext/pull/49 - https://github.com/go-shiori/shiori/pull/651 ## Migration status ### UI Routes | Category | Method | Endpoint | Ready | Tested | Migrated | | ----------- | ------ | ---------------------- | ----- | ------ | -------- | | System | `GET` | /system/liveness | ✅ | ✅ | ✅ | | Bookmarks | `GET` | /bookmarks/:id/content | ✅ | ✅ | ✅ | | Bookmarks | `GET` | /bookmarks/:id/archive | ✅ | ✅ | ✅ | | Bookmarks | `GET` | /bookmarks/:id/thumb | ✅ | ✅ | ✅ | | Bookmarklet | `GET` | /bookmarklet | | | | | UI | `GET` | `/*files*` | ✅ | ✅ | ✅ | ### API routes | Category | Method | Endpoint | Ready | Swagger | Tested | Migrated | | --------- | ----------- | --------------------------- | ----- | ------- | ------ | -------- | | Tags | `GET` | /api/v1/tags | ✅ | ✅ | ✅ | ✅ | | Tags | `POST` | /api/v1/tags | ✅ | ✅ | ✅ | ✅ | | Tags | `PUT/PATCH` | /api/v1/tags/:id | ✅ | ✅ | ✅ | ✅ | | Tags | `DELETE` | /api/v1/tags/:id | ✅ | ✅ | ✅ | ✅ | | Accounts | `GET` | /api/v1/accounts | ✅ | ✅ | ✅ | ✅ | | Accounts | `POST` | /api/v1/accounts | ✅ | ✅ | ✅ | ✅ | | Accounts | `PUT/PATCH` | /api/v1/accounts/:id | ✅ | ✅ | ✅ | ✅ | | Accounts | `DELETE` | /api/v1/accounts/:id | ✅ | ✅ | ✅ | ✅ | | Auth | `GET` | /api/v1/auth/account | ✅ | ✅ | ✅ | ✅ | | Auth | `PUT` | /api/v1/auth/account | ✅ | ✅ | ✅ | ✅ | | Auth | `POST` | /api/v1/auth/login | ✅ | ✅ | ✅ | ✅ | | Auth | `POST` | /api/v1/auth/refresh | ✅ | ✅ | ✅ | ✅ | | Bookmarks | `GET` | /api/v1/bookmarks | | | | | | Bookmarks | `POST` | /api/v1/bookmarks | | | | | | Bookmarks | `PUT` | /api/v1/bookmarks/cache | | | | | | Bookmarks | `GET` | /api/v1/bookmarks/:id | | | | | | Bookmarks | `PUT/PATCH` | /api/v1/bookmarks/:id | | | | | | Bookmarks | `PUT` | /api/v1/bookmarks/:id/cache | | | | | ### Database | Category | SQLite | MySQL | PSQL | | -------- | ------ | ----- | ------ | | `CreateTags` | ✅ | ✅ | ✅ | ## Logic domains - Auth ## Related issues - Fixes https://github.com/go-shiori/shiori/issues/613 - Fixes https://github.com/go-shiori/shiori/issues/571 - Fixes https://github.com/go-shiori/shiori/issues/455 - Fixes https://github.com/go-shiori/shiori/issues/439
kerem 2026-02-25 23:33:57 +03:00
Author
Owner

@stale[bot] commented on GitHub (Aug 21, 2023):

This issue has been automatically marked as stale because it has not had any activity for quite some time.
It will be closed if no further activity occurs.
Thank you for your contributions.

<!-- gh-comment-id:1686883569 --> @stale[bot] commented on GitHub (Aug 21, 2023): This issue has been automatically marked as stale because it has not had any activity for quite some time. It will be closed if no further activity occurs. Thank you for your contributions.
Author
Owner

@fmartingr commented on GitHub (Feb 6, 2024):

Closing in favor of the roadmap.

<!-- gh-comment-id:1930579549 --> @fmartingr commented on GitHub (Feb 6, 2024): Closing in favor of [the roadmap](https://github.com/orgs/go-shiori/projects/2/views/4).
Author
Owner

@rept0id commented on GitHub (May 2, 2025):

Using Gin with it's middlewares will make the project much safer, because what if someone will forget one day to call validateSession() ? This could had been a middleware.

func (h *Handler) ApiRenameTag(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	ctx := r.Context()

	// Make sure session still valid
	err := h.validateSession(r) // <-------------------- here
	checkError(err)
<!-- gh-comment-id:2846489776 --> @rept0id commented on GitHub (May 2, 2025): Using Gin with it's middlewares will make the project much safer, because what if someone will forget one day to call `validateSession()` ? This could had been a middleware. ``` func (h *Handler) ApiRenameTag(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { ctx := r.Context() // Make sure session still valid err := h.validateSession(r) // <-------------------- here checkError(err) ```
Author
Owner

@rept0id commented on GitHub (May 2, 2025):

Let me ask everyone, what is your opinion on Fiber, as an alternative to Gin ?

I haven't used it yet but I see that it's gaining popularity.

<!-- gh-comment-id:2846491307 --> @rept0id commented on GitHub (May 2, 2025): Let me ask everyone, what is your opinion on Fiber, as an alternative to Gin ? I haven't used it yet but I see that it's gaining popularity.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shiori#323
No description provided.