@ -37,6 +37,8 @@ import (
const (
const (
// TODO: delete. don't use this!
// TODO: delete. don't use this!
apCustomHandleDefault = "blog"
apCustomHandleDefault = "blog"
apCacheTime = time . Minute
)
)
type RemoteUser struct {
type RemoteUser struct {
@ -84,6 +86,7 @@ func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Re
p := c . PersonObject ( )
p := c . PersonObject ( )
setCacheControl ( w , apCacheTime )
return impart . RenderActivityJSON ( w , p , http . StatusOK )
return impart . RenderActivityJSON ( w , p , http . StatusOK )
}
}
@ -137,6 +140,7 @@ func handleFetchCollectionOutbox(app *App, w http.ResponseWriter, r *http.Reques
ocp . OrderedItems = append ( ocp . OrderedItems , * a )
ocp . OrderedItems = append ( ocp . OrderedItems , * a )
}
}
setCacheControl ( w , apCacheTime )
return impart . RenderActivityJSON ( w , ocp , http . StatusOK )
return impart . RenderActivityJSON ( w , ocp , http . StatusOK )
}
}
@ -183,6 +187,7 @@ func handleFetchCollectionFollowers(app *App, w http.ResponseWriter, r *http.Req
ocp . OrderedItems = append ( ocp . OrderedItems , f . ActorID )
ocp . OrderedItems = append ( ocp . OrderedItems , f . ActorID )
}
}
* /
* /
setCacheControl ( w , apCacheTime )
return impart . RenderActivityJSON ( w , ocp , http . StatusOK )
return impart . RenderActivityJSON ( w , ocp , http . StatusOK )
}
}
@ -219,6 +224,7 @@ func handleFetchCollectionFollowing(app *App, w http.ResponseWriter, r *http.Req
// Return outbox page
// Return outbox page
ocp := activitystreams . NewOrderedCollectionPage ( accountRoot , "following" , 0 , p )
ocp := activitystreams . NewOrderedCollectionPage ( accountRoot , "following" , 0 , p )
ocp . OrderedItems = [ ] interface { } { }
ocp . OrderedItems = [ ] interface { } { }
setCacheControl ( w , apCacheTime )
return impart . RenderActivityJSON ( w , ocp , http . StatusOK )
return impart . RenderActivityJSON ( w , ocp , http . StatusOK )
}
}
@ -703,3 +709,7 @@ func unmarshalActor(actorResp []byte, actor *activitystreams.Person) error {
return nil
return nil
}
}
func setCacheControl ( w http . ResponseWriter , ttl time . Duration ) {
w . Header ( ) . Set ( "Cache-Control" , fmt . Sprintf ( "public, max-age=%.0f" , ttl . Seconds ( ) ) )
}