import (
"fmt"
"net/http"
"github.com/gorilla/sessions"
)
var (
// key must be 16, 24 or 32 bytes long (AES-128, AES-192 or AES-256)
key = []byte("super-secret-key")
store = sessions.NewCookieStore(key)
)
func secret(w http.ResponseWriter, r *http.Request) {
session, _ := store.Get(r, "cookie-name")
// Check if user is authenticated
if auth, ok := session.Values["authenticated"].(bool); !ok || !auth {
http.Error(w, "Forbidden", http.StatusForbidden)
return
}
// Тут из сессии получили токен — пошли в АПИ за данными
fmt.Fprintln(w, "The cake is a lie!")
}
<?php
$arr = [
[
'name' => 'foo',
'vendor' => 'adidas',
'price' => 100,
],
[
'name' => 'foo',
'vendor' => 'adidas',
'price' => 120,
],
[
'name' => 'bar',
'vendor' => 'adidas',
'price' => 300,
],
];
$res = array_values(
array_reduce($arr, function(array $res, array $item) {
$alias = sprintf('%s_%s', $item['name'], $item['vendor']);
if(!isset($res[$alias])) {
$res[$alias] = $item;
return $res;
}
if($item['price'] < $res[$alias]['price']) {
$res[$alias] = $item;
}
return $res;
}, [])
);
var_dump($res);
можно ли Docker связать с разработкой React Native мобильных приложений?
version: "3"
services:
angular-server:
image: node:14-alpine
environment:
PATH: "/app/node_modules/.bin:$PATH"
volumes:
- ./frontend:/app:delegated
- ./frontend/src:/app/src:consistent
- ./public:/public:delegated
ports:
- "4201:4201"
working_dir: /app
entrypoint: ["ng","serve","--host", "0.0.0.0", "--port", "4201"]