New around here? Register your SA Forums Account here!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ComradeCosmobot
Dec 4, 2004

USPOL July
Presumably you use a query parameter to act on the resource being filtered and the query parameter indicates both that filtering is happening and the resource being used to achieve that filter

Adbot
ADBOT LOVES YOU

necrotic
Aug 1, 2005
I owe my brother big time for this!

HoboMan posted:

ok, again i have not had to design poo poo before.

how to restfully have an endpoint that returns a resource filtered by another resource?

your /foo/bar resource would return a link to /wangs?of=/foo/bar or something like that.

Sapozhnik
Jan 2, 2005

Nap Ghost
URLs are not ids any more than pointers are ids

necrotic
Aug 1, 2005
I owe my brother big time for this!
used the object id then, whatever. point is the parent resource contains links to what you need.

ComradeCosmobot
Dec 4, 2004

USPOL July

Sapozhnik posted:

URLs are not ids any more than pointers are ids

RFC 3986 would beg to disagree.

quote:

A Uniform Resource Identifier (URI) provides a simple and extensible means for identifying a resource.

quote:

The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location").

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





HoboMan posted:

ok, again i have not had to design poo poo before.

how to restfully have an endpoint that returns a resource filtered by another resource?

https://yourdumbservice.com/the-first-resource?the-second-resource=1

Powerful Two-Hander
Mar 9, 2004

Mods please change my name to "Tooter Skeleton" TIA.



necrotic posted:

your /foo/bar resource would return a link to /wangs?of=/foo/bar or something like that.

wtf

if you're using dotnet then you can bind variables out of the url so you can have foo\123\butt\456 and in your controller get fooid as 123 and buttid as 456

you just gotta decorate your controller base route and actions with a binder like foo\{int:fooid} \butt\{int:buttid}

edit: I'm not really sure if that's what you mean but you can also use redirects to actions to hit an endpoint, do something, get the value returned and redirect to another that performs another action off that returned value

ComradeCosmobot
Dec 4, 2004

USPOL July

Powerful Two-Hander posted:

wtf

if you're using dotnet then you can bind variables out of the url so you can have foo\123\butt\456 and in your controller get fooid as 123 and buttid as 456

you just gotta decorate your controller base route and actions with a binder like foo\{int:fooid} \butt\{int:buttid}

edit: I'm not really sure if that's what you mean but you can also use redirects to actions to hit an endpoint, do something, get the value returned and redirect to another that performs another action off that returned value

I think the debate is over how RESTful that API is for the usecase. Maybe OP should clarify the use case a little?

necrotic
Aug 1, 2005
I owe my brother big time for this!

ComradeCosmobot posted:

I think the debate is over how RESTful that API is for the usecase. Maybe OP should clarify the use case a little?

yeah he said restful not hierarchical

pseudorandom
Jun 16, 2010



Yam Slacker

HoboMan posted:

ok, again i have not had to design poo poo before.

how to restfully have an endpoint that returns a resource filtered by another resource?


Assuming you're just trying to GET all of the resources that "contain", for lack of a more generic word, some other resource. In other words, searching for all resources that have some property that matches another resource.

I'd probably use one of two options depending upon what your actual use-case is. First would be a query param on the route for the resource:

/api/butts?kissed_by=[goon_id]

My alternative would be swapping the resources and use a nested route of the single resource by which you're trying to search:

/api/goons/:goonId/kissed_butts

I'd only use the latter if there's an obvious hierarchical relationship between resources. Like, if Bars only exist as children of Foos, then the latter would work (/foos/:fooId/bars). In basically any other case, like if Foos and Bars might be associated but could be coexistent without requiring the other, then I'd go with a query parameter.

The latter is also probably not strict REST but the internet is full of awful blog posts about how to do REST correctly and all of them have different opinions so I have no loving idea.

animist
Aug 28, 2018
sounds like you need graphql OP. or possibly SOAP

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
um pretty sure it's time to create a dsl to handle this for maximum flexibility, unless you can make do with OData (aka the Best Way to REST).

Aramoro
Jun 1, 2012




I'm still not sure what the OP is trying to do. Is the filtering between any two arbitrary services? What even is the use case?

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
it's good to see that even if people don't understand the use case or even its most basic requirements they won't hesitate to suggest solutions that may or may not address the problem

developers.txt

Qtotonibudinibudet
Nov 7, 2011



Omich poluyobok, skazhi ty narkoman? ya prosto tozhe gde to tam zhivu, mogli by vmeste uyobyvat' narkotiki
OP definitely needs SOAP. SOAP makes everything better.

Bloody
Mar 3, 2013

Sagacity posted:

it's good to see that even if people don't understand the use case or even its most basic requirements they won't hesitate to suggest solutions that may or may not address the problem

developers.txt

HoboMan
Nov 4, 2010

yeah it's, as pseudorandom suggested, get all butts kissed by a given goon

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
we just had our architect copy and paste a random blog post* about RESTfulness into our confluence and announce 'start doing this now'

becoming standards document #9801293 that has no relation to our codebase whatsoever and probably never will lol


*it had to the gall to quote roy fielding's dissertation just for a random pull quote about 'URL == resource' yet the rest of the article ignores any important parts of rest and just talks about underscores vs hyphens and poo poo

necrotic
Aug 1, 2005
I owe my brother big time for this!
sounds like every other "restful design doc" ive ever seen

animist
Aug 28, 2018
does anybody actually use self-documenting features of REST apis? github's api has a million extra annotations on every message and they seem pretty pointless to me

leftist heap
Feb 28, 2013

Fun Shoe

animist posted:

does anybody actually use self-documenting features of REST apis? github's api has a million extra annotations on every message and they seem pretty pointless to me

sounds about as useful as other forms of "self documenting"

Aramoro
Jun 1, 2012




animist posted:

does anybody actually use self-documenting features of REST apis? github's api has a million extra annotations on every message and they seem pretty pointless to me

We produce RAML for our which our customers do seem to use, well they complain when we break it anyway.

I made a toy app that uses the RAML to create a visualisation of all the data in the system which is quite cool.

gonadic io
Feb 16, 2011

>>=

animist posted:

does anybody actually use self-documenting features of REST apis? github's api has a million extra annotations on every message and they seem pretty pointless to me

I spent quite a long tine trying to generate swagger from http4s routes, or generating them from a swagger spec file, never really made any progress though.

distortion park
Apr 25, 2011


animist posted:

does anybody actually use self-documenting features of REST apis? github's api has a million extra annotations on every message and they seem pretty pointless to me

I've used it to scrape data off apis backing website frontends

Shaggar
Apr 26, 2006
swagger generation in .net is super easy. just add the swashbuckle package

Bloody
Mar 3, 2013

swashbuckle is fuckin fantastic and the swagger api docs i had on a tool at lastjob were probably my group's most widely used documentation and definitely the most used per hour spent writing

Shaggar
Apr 26, 2006
idk why anyone would bother with something other than .net for web stuff

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

animist posted:

does anybody actually use self-documenting features of REST apis? github's api has a million extra annotations on every message and they seem pretty pointless to me

we're merging with a different company in the same sector and their cto was very excited to tell me that they've started doing the full HATEOAS thing with their new microservice architecture. july is gonna be a fun month

gonadic io
Feb 16, 2011

>>=
yeah swagger works out of the box with e.g. play, just not http4s

Powerful Two-Hander
Mar 9, 2004

Mods please change my name to "Tooter Skeleton" TIA.



florida lan posted:

OP definitely needs SOAP. SOAP makes everything better.

just lol at the idea of goons using SOAP

HoboMan
Nov 4, 2010

i think i'm getting gaslit by my dev tools
literally cant tell what is real anymore

Progressive JPEG
Feb 19, 2003

HoboMan posted:

i think i'm getting gaslit by my dev tools
literally cant tell what is real anymore

I wonder if there's a way to have preprocessor macros that change behavior depending on the time of day or calendar day the build is occurring

builds that only work m-f 9-5 with a 30 minute break for lunch

builds that produce different output on April 1 and/or April 20

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
make can read system environment variables and it can change the values of preprocessor macros with command line arguments to gcc
only step remaining is some job running in the background to update the environment variables based on current datetime

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

HoboMan posted:

i think i'm getting gaslit by my dev tools
literally cant tell what is real anymore

we’re terrible programmers, not dev tools

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

Progressive JPEG posted:

I wonder if there's a way to have preprocessor macros that change behavior depending on the time of day or calendar day the build is occurring

builds that only work m-f 9-5 with a 30 minute break for lunch

builds that produce different output on April 1 and/or April 20


RPATDO_LAMD posted:

make can read system environment variables and it can change the values of preprocessor macros with command line arguments to gcc
only step remaining is some job running in the background to update the environment variables based on current datetime



gcc posted:

__DATE__
This macro expands to a string constant that describes the date on which the preprocessor is being run. The string constant contains eleven characters and looks like "Feb 12 1996". If the day of the month is less than 10, it is padded with a space on the left.
__TIME__
This macro expands to a string constant that describes the time at which the preprocessor is being run. The string constant contains eight characters and looks like "23:59:01".

Share Bear
Apr 27, 2004


i was hoping this wasn't a real domain and now i am contemplating buying it

redleader
Aug 18, 2005

Engage according to operational parameters
rest is dumb and bad


asking here rather than the PL thread, but what are git submodules and why are they so bad?

Arcsech
Aug 5, 2008

redleader posted:

rest is dumb and bad


asking here rather than the PL thread, but what are git submodules and why are they so bad?

git submodules are where one git repo includes a pointer to specific commit in another git repo, that gets checked out inside the main one as a directory

in theory they’re a nice way of breaking up a giant repo into logical chunks in a manageable way

in practice they’re a tire fire and massive pain in the rear end to keep up to date. imo this is mainly a tooling problem, but git devs would do diy dentistry than make a sensible UI decision so it’ll never get any better

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.
what if your git repo could incorporate by reference other git repos? and what if each of those git repos could do the same thing?! and what if none of it worked reliably, you constantly fought with stupid recursive git commands, and you came to wish that you'd just written and checked-in a five line shell script containing some git commands instead?

Adbot
ADBOT LOVES YOU

leftist heap
Feb 28, 2013

Fun Shoe
there are multiple layers of badness to it.

git does not handle submodules well at all. from top to bottom it is way more of a pita than it should be. SVN linked repos were easier to work with ffs.

people also largely use them for lazy, ad-hoc dependency management in a way that's awful, fragile and stupid.


Arcsech posted:

in theory they’re a nice way of breaking up a giant repo into logical chunks in a manageable way

yes, this is effectively ad hoc dependency management and you're basically 100% always better off doing it whatever the "right way" is for your lang/environment

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply