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

Move more server logic to endpoints #110

Open
1 of 3 tasks
joepio opened this issue Mar 11, 2021 · 2 comments
Open
1 of 3 tasks

Move more server logic to endpoints #110

joepio opened this issue Mar 11, 2021 · 2 comments
Labels
lib rust atomic-lib (rust) plugin Should probably be an Atomic Plugin server atomic-server

Comments

@joepio
Copy link
Member

joepio commented Mar 11, 2021

atomic-server has a couple of endpoints that provide a bunch of features:

These tend to return kind of inconsistent responses. Validate only returns an HTML page, and none of them even return atomic resources consistently. For handling collections, sorting and pagination #17 and versioning #42, I've been using Extended Resources - which basically means that (some of) their values are dynamic; they are calculated at runtime. I think this would be a powerful abstraction for the plugin system #73.

So... What are Endpoints?

Let the struct speak for itself:

/// An API endpoint at some path which accepts requests and returns some Resource.
pub struct Endpoint {
  /// The part behind the server domain, e.g. '/versions' or '/collections'. Include the slash.
  pub path: String,
  /// The function that is called when the request matches the path
  pub handle: fn(subject: url::Url, store: &Db) -> AtomicResult<Resource>,
  /// The list of properties that can be passed to the Endpoint as Query parameters
  pub params: Vec<String>,
  pub description: String,
  pub shortname: String,
}

So next up is creating these Endpoints for existing handler on the server.

@joepio joepio added lib rust atomic-lib (rust) plugin Should probably be an Atomic Plugin server atomic-server labels Mar 11, 2021
@joepio
Copy link
Member Author

joepio commented Mar 12, 2021

Maybe the /commit endpoint should also be an.. Endpoint? It's a bit different from the other examples:

  • The /commit endpoint works with POST methods, not GET.
  • It parses the body
  • It does not use query parameters

So where does it fit? Is it an Endpoint? If it is, how do we describe what body is accepted? How do we describe that the user can POST to it instead of GET? Do we introduce a GetEndpoint and a PostEndpoint?

This requires some more thought.

joepio added a commit that referenced this issue Mar 13, 2021
joepio added a commit that referenced this issue Mar 13, 2021
@joepio
Copy link
Member Author

joepio commented Mar 14, 2021

Not sure about the /tpf endpoint. If I move it from server to lib, it will no longer be able to behave like most TPF endpoints do - it will not return a bunch of triples, but a Collection containing Resources. Even if the user would request turtle serialization, it would receive the Collection, and not a bunch of triples that match the pattern.

Maybe I should create a second tpf-like endpoint, and keep the older one? Maybe just have a /collection endpoint which accepts a property and a value, which already is supported by collections...

joepio added a commit that referenced this issue Mar 27, 2021
joepio added a commit that referenced this issue Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib rust atomic-lib (rust) plugin Should probably be an Atomic Plugin server atomic-server
Projects
None yet
Development

No branches or pull requests

1 participant